Scrapy模块是一个很好用的模块,功能强大。最近在学习使用scrapy模块,写了一点小东西,爬取腾讯招聘网的基本信息。
scrapy项目步骤:
1. 创建项目:scrapy startproject xxx
2. 编写items.py文件,用于设置需要保存的字段内容
3. 编写爬虫文件
4. 运行爬虫 scrapy crawl xxx
第一步:创建项目,创建完成,目录如下
第二步:编写items.py文件
列出需要获取的内容。
import scrapy
class TencentItem(scrapy.Item):
# define the fields for your item here like:
#职位名称
positionname = scrapy.Field()
#职位详情链接
positionlink = scrapy.Field()
#职位类别
positiontype = scrapy.Field()
#招聘人数
peoplenum = scrapy.Field()
#工作地点
workLocation = scrapy.Field()
#发布时间
publishTIme = scrapy.Field()
第三步: