爬前叨叨
全站爬虫有时候做起来其实比较容易,因为规则相对容易建立起来,只需要做好反爬就可以了,今天咱们爬取知乎。继续使用scrapy
当然对于这个小需求来说,使用scrapy确实用了牛刀,不过毕竟本博客这个系列到这个阶段需要不断使用scrapy
进行过度,so,我写了一会就写完了。
你第一步找一个爬取种子,算作爬虫入口
https://www.zhihu.com/people/zhang-jia-wei/following
我们需要的信息如下,所有的框图都是我们需要的信息。
获取用户关注名单
通过如下代码获取网页返回数据,会发现数据是由HTML+JSON拼接而成,增加了很多解析成本
class ZhihuSpider(scrapy.Spider):
name =