def get_location(url):
try:
response = request.urlopen(url)
# urllib will follow redirections and it's too much code to tell urllib
# not to do that
return response.geturl()
except socket.timeout:
print('request timeout')
exit()
except request.HTTPError as e:
print(e.code)
except request.URLError as e:
print(e.reason)
exit()
return "fail"
评论列表
文章目录