Python使用scrapy采集时伪装成HTTP/1.1的方法
2015-04-08 10:18
796 查看
添加下面的代码到 settings.py 文件
保存以下代码到单独的.py文件
复制代码 代码如下: from scrapy.core.downloader.webclient import ScrapyHTTPClientFactory, ScrapyHTTPPageGetter
class PageGetter(ScrapyHTTPPageGetter):
def sendCommand(self, command, path):
self.transport.write('%s %s HTTP/1.1\r\n' % (command, path))
class HTTPClientFactory(ScrapyHTTPClientFactory):
protocol = PageGetter
希望本文所述对大家的Python程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- Python基于scrapy采集数据时使用代理服务器的方法
- 讲解Python的Scrapy爬虫框架使用代理进行采集的方法
- python scrapy 网络采集使用代理的方法
- 讲解Python的Scrapy爬虫框架使用代理进行采集的方法
- Python使用scrapy采集数据时为每个请求随机分配user-agent的方法
- Python使用scrapy采集数据过程中放回下载过大页面的方法
- 【python】【scrapy】使用方法概要(二)
- python中使用urllib2伪造HTTP报头的2个方法
- 【python】【scrapy】使用方法概要(三)
- python scrapy爬虫爬取图片简易方法,使用Images模块
- scrapy一些非常实用资料整理,与其他mongdb、django、redis、solr、tor结合使用以及用Python脚本调用等等方法
- WCF服务中的方法使用httpwebquest时网站无法响应HTTP/1.1_Server Too Busy
- Requests: 让 HTTP 服务人类(Python第三方模块requests介绍及使用方法)
- 使用httplib模块来制作Python下HTTP客户端的方法
- Python自定义scrapy中间模块避免重复采集的方法
- Python模仿POST提交HTTP数据及使用Cookie值的方法
- python中使用urllib2伪造HTTP报头的2个方法
- Python httplib,smtplib使用方法
- scrapy在采集网页时使用随机user-agent的方法
- Python中使用socket发送HTTP请求数据接收不完整问题解决方法