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. 【C++】【TinyXml】xml文件的读写功能使用——写xml文件

    TinyXml工具是常用比较简单的C++中xml读写的工具 需要加载 #include "TinyXml\tinyxml.h" 在TinyXML中,根据XML的各种元素来定义了一些 ...

  2. delphi2009(10,xe)下indy10发送utf8字符串

    最近实现一个功能,使用delphi2009以TCP调用Java端的接口,接口要求先发送字符串的长度,然后再发送字符串内容,并且字符串要求是utf8格式的 调试了好长时间,才终于发现解决办法,或者说发现 ...

  3. centos搭建svn服务器并同步到web目录

    yum install subversion mkdir -v /root/svn cd /root/svn svnadmin create web cd web/conf/ vi passwd te ...

  4. iOS UITableView动态隐藏或显示Item

    通过改变要隐藏的item的高度实现隐藏和显示item 1.创建UITableView #import "ViewController.h" @interface ViewContr ...

  5. SpringBoot简易搭建

    1.建立maven工程 2.打开pom文件, 将以下配置拷贝过去 <parent> <groupId>org.springframework.boot</groupId& ...

  6. 微信小程序把玩(十)swiper组件

    原文:微信小程序把玩(十)swiper组件 Android写过轮播图的痛楚只有写过的知道,相对还是比较麻烦的,并没有一个轮播图组件,有个ViewPage也需要自己定制,IOS则多用UIScroller ...

  7. Windows 10 版本信息

    原文 https://technet.microsoft.com/zh-cn/windows/release-info Windows 10 版本信息 Microsoft 已更新其服务模型. 半年频道 ...

  8. Rendering in Delphi using TCanvas (FMX)

    BY CRAIG CHAPMAN · PUBLISHED 2015-08-05 · UPDATED 2015-08-20   I have a customer with an application ...

  9. LINUX下QT FOR ARM开发环境搭建过程 (使用qt-x11-opensource-src-4.5.2.tar.gz进行编译)

    在PC上,我们需要得到两个版本的Qt,分别是:Qt-4.5.2和QtEmbedded-4.5.2-arm.前者包括了Qt Designer等基本工具,用于在PC上对程序的开发调试,使我们能确保程序放到 ...

  10. 为什么有如此多的C++测试框架 - from Google Testing Blog

    Why Are There So Many C++ Testing Frameworks? by Zhanyong Wan (Software Engineer) 最近貌似有很多人正在开发他们自己的C ...