def send_http(self, url):
o = urlparse(url)
r = 0
try:
conn = httplib.HTTPConnection(o[1], timeout=self.timeout)
if o[4]:
conn.request('GET', o[2] + o[3] + '?' + o[4], headers=self.headers)
else:
conn.request('GET', o[2] + o[3], headers=self.headers)
r = conn.getresponse()
logger.info('%s %s' % (url, r.status))
time.sleep(self.delay)
except (httplib.HTTPException, socket.timeout, socket.gaierror, Exception), e:
logger.error('url %s is unreachable, Exception %s %s' % (url, e.__class__.__name__, e))
print 'url %s is unreachable, Exception %s %s' % (url.encode('utf-8'), e.__class__.__name__, e)
pass
return r
评论列表
文章目录