美文网首页
scrapy细节

scrapy细节

作者: comboo | 来源:发表于2016-05-31 23:32 被阅读44次

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.

相关文章

  • scrapy细节

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

  • python scrapy极细拆解,打开Spider类看内容,顺

    本篇博客为你带来 scrapy.Spider 模块中的相关函数与类,带你再一次认识 scrapy 的细节。 本次采...

  • 简单 Scrapy 使用小结

    Scrapy 安装Scrapy pip install scrapy Scrapy Doc 查看Scrapy的文档...

  • scrapy框架

    一、scrapy简介 二、scrapy原理 三、scrapy工作流程 四、scrapy框架的创建 五、scrapy...

  • Scrapy笔记

    Scrapy笔记 安装scrapy框架: 安装scrapy:通过pip install scrapy即可安装。 如...

  • scrapy笔记

    1 scrapy的运行原理 参考:Learning Scrapy笔记(三)- Scrapy基础Scrapy爬虫入门...

  • Scrapy基础(一): 安装和使用

    安装 新建scrapy项目 目录 scrapy模板 使用pycharm调试scrapy执行流程 scrapy 终端...

  • 学会运用爬虫框架 Scrapy (三)

    上篇文章介绍 Scrapy 框架爬取网站的基本用法。但是爬虫程序比较粗糙,很多细节还需打磨。本文主要是讲解 Scr...

  • python爬虫13:scrapy

    scrapy的结构 scrapy的工作原理 scrapy的用法

  • Scrapy笔记

    Scrapy笔记 pip 指定源安装模块 创建Scrapy项目 创建Scrapy爬虫程序 启动Scrapy爬虫 在...

网友评论

      本文标题:scrapy细节

      本文链接:https://www.haomeiwen.com/subject/zychdttx.html