返回信息流背景:网址是https打头的,比如https://kyfw.12306.cn/otn/leftTicket/init,需要用代理访问这个网站做些爬虫。
问题:看了官方文档说可以,https://docs.python.org/2.7/library/urllib2.html?highlight=urllib2,但是实测以及google后发现,urllib2不是很支持通过代理获取https网址的信息。
proxy_ip ={'http':'127.0.0.1','https':'127.0.0.1'}
proxy_support =urllib2.ProxyHandler(proxy_ip)
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
request = urllib2.Request(each_combination_url,headers=headers)
combination_read=urllib2.urlopen(request).read()
combination_read=urllib2.urlopen(request).read()
File "C:\Python27\lib\urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 404, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 422, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1222, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Python27\lib\urllib2.py", line 1184, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 10061] >
那如果一定要用代理(比如goagent)来访问这个https网站的话,该如何实现呢?还有别的库么?谢谢!
这是一条镜像帖。来源:北邮人论坛 / python / #5610同步于 2015/3/16
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖
【求问】urllib2是不是不支持https的代理?
shaonianpai
2015/3/16镜像同步6 回复
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
暂时木有,求问还有啥靠谱的代理?
难道是因为goagent不支持https么
【 在 Chon 的大作中提到: 】
: 你试过除了goagent以外的其他代理么?
额……算了我不给自己做广告了
goagent没用过,貌似是不支持https的吧。
【 在 shaonianpai 的大作中提到: 】
: 暂时木有,求问还有啥靠谱的代理?
: 难道是因为goagent不支持https么
没事呀 能解决眼前的问题就好 我不介意的~~
【 在 Chon 的大作中提到: 】
: 额……算了我不给自己做广告了
:
: goagent没用过,貌似是不支持https的吧。
: 【 在 shaonianpai 的大作中提到: 】
: : 暂时木有,求问还有啥靠谱的代理?
: : 难
: .........
发自「贵邮」
后者好用么?有python兼容的模块?
【 在 reverland 的大作中提到: 】
: 一般tsocks python。或者proxychains
: 来自「北邮人论坛手机版」