class my_proxy(object): def process_request(self, request, spider): request.meta['proxy'] = 'http-dyn.abuyun.com:9010' proxy_name_pass = b'XXXXXXXXXXXXXX:YYYYYYYYYYYY' encode_pass_name = base64.b64encode(proxy_name_pass) request.headers['Proxy-Authorization'] = 'Basic' + encode_pass_name.decode() #windows10系统下 报错 Traceback (most recent call last): File "D:\Python\Python36\lib\site-packages\scrapy\core\downloader\middleware.py", line 43, in process_request defer.returnValue((yield download_func(request=request,spider=spider)))scrapy.core.downloader.handlers.http11.TunnelError: Could not open CONNECT tunnel with proxy http-dyn.abuyun.com:9010 [{'status': 407, 'reason': b'Proxy Authentication Required'}] 2018-10-11 21:47:17 [scrapy.core.engine] INFO: Closing spider (finished) 求助大神帮助!!!!!
已解决,
request.headers['Proxy-Authorization'] = 'Basic' + encode_pass_name.decode() 'Basic' -----加空格------> 'Basic '