python
报错
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
File "/usr/lib/python2.6/threading.py", line 484, in run
File "dxcad.py", line 243, in threadget
File "dxcad.py", line 181, in gethtml
File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
File "/usr/lib/python2.6/urllib2.py", line 391, in open
File "/usr/lib/python2.6/urllib2.py", line 409, in _open
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
File "/usr/lib/python2.6/urllib2.py", line 1190, in http_open
File "/usr/lib/python2.6/urllib2.py", line 1164, in do_open
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'error'
代码
def gethtml(url):
encoding_support = ContentEncodingProcessor
prodom=proxylist[random.randint(0,proxn)]
proxy_support = urllib2.ProxyHandler({'http':prodom})
opener = urllib2.build_opener(proxy_support,encoding_support,urllib2.HTTPHandler)
urllib2.install_opener(opener)
try:
bpanhtml = urllib2.urlopen(url,timeout = 2).read()
except Exception,e:
print e
return gethtml(url)
return bpanhtml
求教
慕哥6287543
相关分类