[email protected]:/$ python2.7
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> url1 = 'http://www.google.com'
>>> url2 = 'https://www.google.com'
>>> f = urllib.urlopen(url1)
>>> f = urllib.urlopen(url2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 211, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 355, in open_http
'got a bad status line', None)
IOError: ('http protocol error', 0, 'got a bad status line', None)
>>>
當我嘗試連接到https站點時,使用urllib我得到了上面的錯誤。 代理正確設置。調試python代碼,我注意到urllib.py中沒有執行ssl庫上的導入。所以,https呼叫也不會執行。任何人都可以幫助我嗎?我必須使用urllib,而不是urllib2或另一個。提前致謝。使用python2.7上的urllib無法訪問https站點
看看這裏的想法:http://stackoverflow.com/questions/3747037/urllib-py-doesnt-work-with-https –