1.目标网址:腾讯招聘
2.需求:
爬取招聘岗位信息
翻页
虚假url
3.数据加载方式:动态和静态
动态加载
简单抓包
第一页:https://careers.tencent.com/tencentcareer/api/post/Query?timestamp=1651906031606&countryId=&cityId=&bgIds=&productId=&categoryId=&parentCategoryId=&attrId=&keyword=&pageIndex=2&pageSize=10&language=zh-cn&area=cn

第四页真实的url:https://careers.tencent.com/tencentcareer/api/post/ByPostId?timestamp=1652528559857&postId=1450028841794805760&language=zh-cn
获取每一页解析的postid

操作步骤

spider的使用

custom_settings:
crawler:这个属性是方法from_crawler设置的,可以通过它获取settings里的配置信息

Request对象

priority: 请求的优先级 默认是0
dont_filter: request不去重 设置为True 默认为False
errback:错误处理方式
flags:请求的标志
cb_kwargs:回调方法的额外参数

response

urljoin: 是对url的一个拼接处理
follow/follow_all:是一个根据相对url来生成后续请求路径的一个方法
Response还有几个子类,TextResponse和HtmlResponse,回调函数返回的是HtmlResponse,他们还有几个常用的方法或属性
json:scrapy 2.0版本以上的可以直接用json方法直接将text转为json