刚开始使用http中间件做爬虫其实蛮多坑的,最主要的坑就是编码问题,有很多中文网站的采用的gb2313的编码方式,这个在爬到的报文解析就很蛋碎, 因为http中间件对utf-8支持的比较好,所以针对这一点我们需要对于gb2312的网站做编码转换处理 这里我使用了mongoose,所以node执行js会先链接test数据库 这里爬了百度阅读的数据,但是爬下来的图片链接在本地网页是不能使用的,百度图片服务器做了请求筛选 代码如下: /** * Created by Myco on 2016/3/15…
抓取到的item 会被发送到Item Pipeline进行处理 Item Pipeline常用于 cleansing HTML data validating scraped data (checking that the items contain certain fields) checking for duplicates (and dropping them) storing the scraped item in a database 目录 [隐藏] 1 写一个自己的item pip…