reason: [Errno 10060]

import urllib2

#req = urllib2.Request('http://localhost/thinkphp323/Application/')
req = urllib2.Request('http://www.xxxxx.com')
try:
    urllib2.urlopen(req)
except urllib2.URLError, e:
    if hasattr(e, "code"):
        print "code:",e.code
    if hasattr(e, "reason"):
        print "reason:",e.reason
else:
    print "OK"

 

 

C:\Python27\python.exe D:/PycharmProjects/PySpider/HTTPurlError.py
reason: [Errno 10060] 

 

posted @ 2018-01-08 19:32  sky20080101  阅读(88)  评论(0)    收藏  举报