def get_html(url):
for i in range(3):
try:
head=headers
head['Referer']='https://www.bing.com'
rsp = requests.get(url, headers=head, timeout=5)
except requests.ConnectionError, requests.ConnectTimeout:
# print e.message, 'bing?????????5?'
time.sleep(5)
continue
if rsp.status_code == 200:
root = etree.HTML(rsp.text)
return root
else:
time.sleep(5)
评论列表
文章目录