class my_proxy(object): def process_request(self,request,spider): request.meta['proxy']='http-cla.abuyun.com:9030' proxy_name_pass=b'H211EATS905745KC:F8FFBC929EB7D5A7' encode_pass_name=base64.b64encode(proxy_name_pass) request.headers['Proxy-Authorization']='Basic '+encode_pass_name.decode()
import base64 # 代理服务器 proxyServer = "http://http-dyn.abuyun.com:9020" # 代理隧道验证信息 proxyUser = "xxxxxx" proxyPass = "xxxxxx" # for Python2 proxyAuth = "Basic " + base64.b64encode(proxyUser + ":" + proxyPass) # for Python3 #proxyAuth = "Basic " + base64.urlsafe_b64encode(bytes((proxyUser + ":" + proxyPass), "ascii")).decode("utf8") class ProxyMiddleware(object): def process_request(self, request, spider): request.meta["proxy"] = proxyServer request.headers["Proxy-Authorization"] = proxyAuth
request.meta['Proxy'] = 'http-pro.abuyun.com:9010',在http-pro.abuyun.com:9030前面加上http://就可以了
request.meta['Proxy'] = 'http-pro.abuyun.com:9010'
改成
request.meta['Proxy'] = ',问题解决
request.meta['Proxy'] = 'http-pro.abuyun.com:9010'
我是把‘proxy'改为'Proxy'后好像可以了
ERROR: Error downloading <GET https://movie.douban.com/top250>: Could not open CONNECT tunnel with proxy http-cla.abuyun.com:9030 [{'status': 407, 'reason': b'Proxy Authentication Required'}]这个怎么解决
那不清楚了,我以为是加b错误
你python是哪个版本