scrapy polipo

来源:互联网 发布:经济数据库都有什么 编辑:程序博客网 时间:2024/05/29 13:52

middlewares.py:

# Importing base64 library because we'll need it ONLY in case if the proxy we are going to use requires authenticationimport base64 # Start your middleware classclass ProxyMiddleware(object):    # overwrite process request    def process_request(self, request, spider):        # Set the location of the proxy        request.meta['proxy'] = "http://127.0.0.1:8118"

setting.py:

DOWNLOADER_MIDDLEWARES = {    'scrapy.contrib.downloadermiddleware.httpproxy.HttpProxyMiddleware': 110,    'amazon.middlewares.ProxyMiddleware': 100,}

0 0