scrapy细节

1,Request方面callback=self.parse。注意不是self.parse()也不是callback = 'parse'

2,xpath里面文本提取要用text()

3,item生成对象的时候要在for循环之内

4,换ip,换cookie,换ua都是一样的,先调用中继器,在中继器构造相应的方法。

注意

headers(dict) – the headers of this request. The dict values can be strings (for single valued headers) or lists (for multi-valued headers). IfNoneis passed as value, the HTTP header will not be sent at all.

cookies(dict or list) –

the request cookies. These can be sent in two forms.

Using a dict:

request_with_cookies=Request(url="http://www.example.com",cookies={'currency':'USD','country':'UY'})

Using a list of dicts:

request_with_cookies=Request(url="http://www.example.com",cookies=[{'name':'currency','value':'USD','domain':'example.com','path':'/currency'}])

翻译成人话就是,cookie和header是request的一个词典类型的参数,ua是header里面的一个建。

至于代理,可以用mate存储。

meta(dict) – the initial values for theRequest.metaattribute. If given, the dict passed in this parameter will be shallow copied.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,099评论 19 139
  • 原来岁月太长,可以丰富、也可以荒凉,能忘记结果,未必能忘记遇上......
    琴海爱阅读 243评论 0 1