scrapy 爬网站的时候 加代理报错

2019-01-05 10:42:39 +08:00
 Ewig
这个网站加了代理报错如下
网址: http://www.csrc.gov.cn/pub/newsite/xxpl/yxpl/index

自己的 middleware 组件
import base64


class proxy_middleware(object):

def __init__(self):
proxy_host = "t.1n.cn"
proxy_port = "**"
self.username = "***"
self.password = "***"
self.proxies = {"https": "https://{}:{}/".format(proxy_host, proxy_port)}
self.proxy_server = 'https://w5.t.16yun.cn:6469'
self.proxy_authorization = 'Basic ' + base64.urlsafe_b64encode(
bytes((self.username + ':' + self.password), 'ascii')).decode('utf8')

def process_request(self, request, spider):
request.meta['proxy'] = self.proxy_server
request.headers['Proxy-Authorization'] = self.proxy_authorization




2019-01-05 10:37:46 [csrc][scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET http://www.csrc.gov.cn/pub/newsite/xxpl/yxpl/index_1.html> (failed 1 times): [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('SSL routines', 'ssl3_get_record', 'wrong version number')]>]
2113 次点击
所在节点    Python
10 条回复
xz
2019-01-05 10:45:49 +08:00
你们公司在哪?还招人吗?
PulpFunction
2019-01-05 10:46:26 +08:00
网址都 404 了
1n.cn 是啥代理
Ewig
2019-01-05 10:47:21 +08:00
Ewig
2019-01-05 10:48:05 +08:00
Ewig
2019-01-05 10:51:51 +08:00
@PulpFunction 我故意写错的,是一个动态代理
meik2333
2019-01-05 11:05:24 +08:00
难道 1n.cn 就是下面那个 w5.t.16yun.cn:6469 么?
misaka19000
2019-01-05 11:09:15 +08:00
又见不格式化的 python 代码,v 站的用户素质已经这样了吗?
PulpFunction
2019-01-05 11:30:05 +08:00
建议你看看官方文档,我是 splashrequests
形式如:
SplashRequest ( url, callback, endpoint, args{lua_source.......proxy})

你看你用什么 Request 应该大同小异

换个代理,有的不好使
Ewig
2019-01-05 13:29:21 +08:00
@PulpFunction 解决了,谢谢!
gaoan000
2019-01-05 14:43:45 +08:00
@xz 杀人诛心

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/524076

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX