scrapy中间件middlewares中当我们使用代理爬取页面的时候,提示如下错误:
Could not open CONNECT tunnel with proxy 14.115.105.155:808 [{'status': 307, 'reason': b'Temporary Redirect'}]
很有可能已加入对方黑名单,可以用如下命令捕获异常,并删除这个代理:
from scrapy.core.downloader.handlers.http11 import TunnelErrorclass RandomProxyMiddleware(object):......def process_exception(self,request,exception,spider):if isinstance(exception,TunnelError):pass