meta The initial values for the Request.meta attribute. If given, the dict passed in this parameter will be shallow copied.该参数也是字典形式 , 是为了在spider类的多个parse函数之间传递信息 , 见 知乎 。 注意Response对象也有一个它对应的Request对象 :The Request object that generated this response. This attribute is assigned in the Scrapy engine, after the response and the request have passed through all Downloader Middlewares In particular, this means that:HTTP redirections will cause the original request (to the URL before redirection) to be assigned to the redirected response (with the final URL after redirection).Response.request.url doesn’t always equal Response.urlThis attribute is only available in the spider code, and in the Spider Middlewares, but not in Downloader Middlewares (although you have the Request available there by other means) and handlers of the response_downloaded signal.But Unlike the Response.request attribute, the Response.meta attribute is propagated along redirects and retries, so you will get the original Request.meta sent from your spider.Response obejct这里仅介绍一些reponse对象的属性:
- url 即该response的来源url
- status 即该response的状态码
- headers response的响应头 , 形式为dict
- body response的相应数据体 , 形式为bytes
- request response对应的Request对象 , 对于它上文已经介绍 , 即Response.url可能不等于Reponse.request.url , 因为redirection的原因
SettingsSettings can be populated using different mechanisms, each of which having a different precedence. Here is the list of them in decreasing order of precedence:
- Command line options (most precedence)
- Settings per-spider
- Project settings module(settings.py)
- Default settings per-command
- Default global settings (less precedence)
一般我们直接在settings.py文件中对其进行修改 , 常见需要增改的有:user-agent指定 , ITEM_PIPELINES解除注释以开启pipeline功能 , LOG_LEVEL和LOG_FILE指定 , ROBOTSTXT_OBEY设为False等等 。
【Scrapy框架初探】
推荐阅读
-
交警|珠海滴滴司机国庆车流中飙120km/h,车上夫妇还嫌慢!交警将他们…
-
-
-
华为发力,40万跑分+8+128GB+屏幕指纹跌至1798,还有4800万三摄
-
同样是养女儿,当17岁黄多多和贝儿、森碟站在一起,差别就出来了!
-
凤凰娱乐|刘忻为了乐队的夏天拒绝乘风破浪,苗圃吕一却向节目组毛遂自荐
-
王者荣耀|王者荣耀吉哥:学会老夫子的无限减伤与飘逸大招,你就能出类拔萃!
-
谭咏麟|港乐劲歌金曲金奖: 谁的金曲金奖最有含金量?
-
姜宇星|路人王大魔王参加CBA选秀!12次参赛拿11冠 能上演草根逆袭么?
-
-
-
吃法|面粉新吃法,不用发酵,开水一烫,无任何添加剂,个个空心
-
家里|家里的菜园子不知道栽种些什么,种点它,一茬一茬用不完!
-
太平洋电脑网 致力于提升开源软件的安全性,OpenSSchengF成立
-
-
-
#猎鹰防务观察#人们呼吁他取代拜登,成为民主党候选人,州长科莫系出名门
-
-
打野|阿古朵定位是坦克,但是真的要全部出肉吗?你会秒刷三野吗?
-
年代|战争年代观看《白毛女》,八路军各部有规矩,枪膛里不许装子弹