Proxy Port 与 Scrapy 框架的集成
pypi.org/project/scrapyproxyport - PyPi.org 上的页面
github.com/proxyport/scrapy-proxyport - github 上的源代码
github.com/proxyport/scrapy-proxyport - github 上的源代码
先决条件
安装
$ pip install scrapyproxyport
入门
$ export PROXY_PORT_API_KEY=<API_KEY>
或在 settings.py 中.
# inside <your_project>/settings.py
PROXY_PORT_API_KEY = '<API_KEY>'
DOWNLOADER_MIDDLEWARES = {
# 在 CookiesMiddleware 之前添加带订单号的中间件
'scrapyproxyport.middlewares.ProxyMiddleware': 898,
'scrapy.downloadermiddlewares.cookies.CookiesMiddleware': 899,
}
DOWNLOAD_TIMEOUT = 10
RETRY_TIMES = 20
DUPEFILTER_CLASS = 'scrapy.dupefilters.BaseDupeFilter'