def check_web_server(host, port, path):
h = httplib.HTTPConnection(host, port)
h.request('GET',path)
resp = h.getresponse()
print 'HTTP Response:'
print ' status =', resp.status
print ' reason =', resp.reason
print 'HTTP Headers:'
for hdr in resp.getheaders():
print ' %s: %s' % hdr
我这样调用这个函数,check_web_server('www.python.org',80,'/')
但它给了我这个错误
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
您可以在这里清楚地看到代码 http://pastebin.com/V9KpGkvw
我已经在 Stackoverflow 中搜索过,但我没有找到任何相关问题,对不起,我是网站新手,如果我做错了什么。