import scrapy
from scrapy.spider import CrawlSpider,Rule
from scrapy.linkextractors import LinkExtractor
from tencent.items import TencentItem class TencentSpider(CrawlSpider):
    name = "Tencent"
    allowed_domains = ["tencent.com"]
    # url="http://hr.tencent.com/position.php?&start="
    # offset=0
    start_urls = [ "http://hr.tencent.com/position.php?&start=0#a"]     page_link=LinkExtractor(allow=("start=\d+"))     rules=[
            Rule(page_link,callback = "parseContent",follow=True)
    ]     def parseContent(self, response):
        list=response.xpath('//tr[@class="even"] | //tr[@class="odd"]')
        for infos in list:
            item=TencentItem()
            item['positionname']=infos.xpath("./td[1]/a/text()").extract()[0]
            item['positionlink']=infos.xpath("./td[1]/a/@href").extract()[0]
            item['positionType']=infos.xpath("./td[2]/text()").extract()
            item['positionNum']=infos.xpath("./td[3]/text()").extract()[0]
            item['positionLocation']=infos.xpath("./td[4]/text()").extract()[0]
            item['publishTime']=infos.xpath("./td[5]/text()").extract()[0]             yield item 运行: scrapy crawl Tencent
#注意:千万记住callback不能写 parse,由于CrawlSpider使用parse方法来实现其逻辑,如果覆盖了 parse方法,crawl spider将会运行失败

scrapy基础知识之 CrawlSpiders(爬取腾讯校内招聘):的更多相关文章

  1. scrapy基础知识之 CrawlSpiders爬取lagou招聘保存在mysql(分布式):

    items.py import scrapy class LagouItem(scrapy.Item): # define the fields for your item here like: # ...

  2. 利用scrapy爬取腾讯的招聘信息

    利用scrapy框架抓取腾讯的招聘信息,爬取地址为:https://hr.tencent.com/position.php 抓取字段包括:招聘岗位,人数,工作地点,发布时间,及具体的工作要求和工作任务 ...

  3. scrapy基础知识之 CrawlSpiders:

    通过下面的命令可以快速创建 CrawlSpider模板 的代码: scrapy genspider -t crawl spidername xx.com LinkExtractors class sc ...

  4. scrapy 第一个案例(爬取腾讯招聘职位信息)

    import scrapy import json class TzcSpider(scrapy.Spider): # spider的名字,唯一 name = 'tzc' # 起始地址 start_u ...

  5. 0.Python 爬虫之Scrapy入门实践指南(Scrapy基础知识)

    目录 0.0.Scrapy基础 0.1.Scrapy 框架图 0.2.Scrapy主要包括了以下组件: 0.3.Scrapy简单示例如下: 0.4.Scrapy运行流程如下: 0.5.还有什么? 0. ...

  6. 【图文详解】scrapy爬虫与动态页面——爬取拉勾网职位信息(2)

    上次挖了一个坑,今天终于填上了,还记得之前我们做的拉勾爬虫吗?那时我们实现了一页的爬取,今天让我们再接再厉,实现多页爬取,顺便实现职位和公司的关键词搜索功能. 之前的内容就不再介绍了,不熟悉的请一定要 ...

  7. 简单的scrapy实战:爬取腾讯招聘北京地区的相关招聘信息

    简单的scrapy实战:爬取腾讯招聘北京地区的相关招聘信息 简单的scrapy实战:爬取腾讯招聘北京地区的相关招聘信息 系统环境:Fedora22(昨天已安装scrapy环境) 爬取的开始URL:ht ...

  8. Scrapy 通过登录的方式爬取豆瓣影评数据

    Scrapy 通过登录的方式爬取豆瓣影评数据 爬虫 Scrapy 豆瓣 Fly 由于需要爬取影评数据在来做分析,就选择了豆瓣影评来抓取数据,工具使用的是Scrapy工具来实现.scrapy工具使用起来 ...

  9. 使用Scrapy框架爬取腾讯新闻

    昨晚没事写的爬取腾讯新闻代码,在此贴出,可以参考完善. # -*- coding: utf-8 -*- import json from scrapy import Spider from scrap ...

随机推荐

  1. WPF 通过CommandBinding捕获命令

    RoutedCommand与业务逻辑无关,业务逻辑是通过CommandBinding来实现 using System; using System.Collections.Generic;using S ...

  2. 图像滤镜艺术---LOMO Filter

    原文:图像滤镜艺术---LOMO Filter LOMO Filter LOMO是一种概念,即强调感受.机缘,弱化摄影技巧,不确定性和随意性是LOMO最大特点.LOMO源于Lomography,LOM ...

  3. WPF ListView 数据懒加载

    实现方式:当滑动条触底时,加载数据 xaml代码: <ListView ScrollViewer.ScrollChanged="ListView_ScrollChanged" ...

  4. C#判断系统是32位还是64位

    bool type; type = Environment.Is64BitOperatingSystem; Console.WriteLine(type);

  5. Android 8通过startService引起crash问题

    Android 8.0 不再允许后台service直接通过startService方式去启动,否则就会引起IllegalStateException.解决方式: if (Build.VERSION.S ...

  6. 使用sikuli软件进行自动化编程

    因为工作上的需要,某个信息系统不健全,因此仅仅需要一个一个的点击确认,客户端是网页版本的,抓包太复杂了,如何快速的能够自动化操作? 想到了之前学习python的时候,发现了一个基于java的图片编程软 ...

  7. 在windows下的QT编程中的char*,wchar_t*与QString之间的转换(利用reinterpret_cast和_stprintf函数,fromWCharArray从字符数组里读取数据)

    http://blog.csdn.net/yangxiao_0203/article/details/7422660 转自http://hi.baidu.com/zj41342626/blog/ite ...

  8. Codility---Dominator

    Task description A zero-indexed array A consisting of N integers is given. The dominator of array A ...

  9. asp.net mvc实现微信外H5支付方法

    一.微信支付方式介绍 微信提供了各种支付方式,试用于各种不同的支付场景,主要有如下几种: 1.刷卡支付 刷卡支付是用户展示微信钱包内的“刷卡条码/二维码”给商户系统扫描后直接完成支付的模式.主要应用线 ...

  10. Spark之SparkSql

    -- Spark SQL 以编程方式指定模式 val sqlContext = new org.apache.spark.sql.SQLContext(sc) val employee = sc.te ...