scrapy框架爬取51job网
来源:互联网 发布:线条随鼠标特效源码 编辑:程序博客网 时间:2024/06/10 05:00
# -*- coding: utf-8 -*-import scrapyfrom scrapy.spiders import CrawlSpider,Rulefrom scrapy.linkextractors import LinkExtractorfrom manhua.items import ManhuaItemclass DemoSpider(CrawlSpider): name = "demo" #这里爬取两个网站,一个是php工程师,一个是python工 程师 start_urls=["http://search.51job.com/list/000000,000000,0000,00,9,99,php,2,1.html?lang=c°reefrom=99&stype=&workyear=99&cotype=99&jobterm=99&companysize=99&radius=-1&address=&lonlat=&postchannel=&list_type=&ord_field=&curr_page=&dibiaoid=0&landmark=&welfare=", "http://search.51job.com/list/000000,000000,0000,00,9,99,Python%25E5%25BC%2580%25E5%258F%2591%25E5%25B7%25A5%25E7%25A8%258B%25E5%25B8%2588,2,1.html?lang=c&stype=&postchannel=0000&workyear=99&cotype=99°reefrom=99&jobterm=99&companysize=99&providesalary=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&line=&specialarea=00&from=&welfare=" ] rules={ Rule(LinkExtractor(allow="http:\/\/search.51job.com\/list\/",restrict_xpaths="//div[@class='p_in']"),callback="paser_item",follow=True), # Rule(LinkExtractor(allow="")) } def paser_item(self,response): divs=response.xpath("//div[@class='el']") item=ManhuaItem() for div in divs: try: item['duty'] = div.xpath("./p/span/a/text()")[0].extract().strip() item['time'] = div.xpath("./span[4]/text()").extract() item['name'] = div.xpath("./span[1]/a/text()").extract() item['location'] = div.xpath("./span[2]/text()").extract() item['sallary'] = div.xpath("./span[3]/text()").extract() yield item except Exception: pass*******************items.py********************import scrapyclass ManhuaItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() name=scrapy.Field() #公司名称 duty=scrapy.Field() #工作的标题 location=scrapy.Field() #公司地址 sallary=scrapy.Field() #薪水 time=scrapy.Field() #时间 ********************************************** 最后在控制台运行即可:scrapy crawl demo -o file.csv这里我大概爬了四万多条数据,如果想要数据的可以私聊我
0 0
- scrapy框架爬取51job网
- Scrapy爬虫实战(三)----------使用cookies爬取51job
- scrapy爬虫实战(四)--------------登陆51job并使用cookies进行爬取
- Python爬虫框架Scrapy:爬取校花网
- Scrapy 爬虫框架爬取网页数据
- scrapy框架爬虫定时爬取
- scrapy框架爬取校花网站
- 【scrapy】爬取框架使用流程(1)
- Scrapy框架爬取详细步骤
- python scrapy框架爬取CNKI数据
- 使用python scrapy爬虫框架 爬取科学网自然科学基金数据
- python爬虫(16)使用scrapy框架爬取顶点小说网
- 用scrapy框架爬取js交互式表格数据
- Python 采用Scrapy爬虫框架爬取豆瓣电影top250
- 爬虫框架scrapy,爬取豆瓣电影top250
- scrapy框架爬取校花网站的升级版
- Python爬虫:用Scrapy框架爬取漫画
- 使用scrapy框架爬取豆瓣电影top250信息
- Android《第一行代码》第4章 笔记
- java多态使用时,如果想要调用子类特有属性如何做.
- 字符串操作
- 全国政协十二届五次会议开幕,汪国新委员出席并听取会议报告
- pb_ds库的讲解和应用举例
- scrapy框架爬取51job网
- php 与java在实现抽象方法上的不同
- Lucene Field域的详解(二)
- java正则表达式详解
- concat方法
- BDD1.4更换Logo图片
- JavaScript—定义 getters 与 setters
- 如何确定特定情况下可变参数函数的参数个数
- 175. Combine Two Tables