def get_to_url(self, request_url, get_data):
if get_data == "":
tmp_url = request_url
else:
tmp_url = request_url + "?" + get_data
#print tmp_url
#print self.my_cookie
req = urllib.request.Request(
url=request_url,
)
req.add_header('Cookie', self.my_cookie)
#print req.headers
#print req.data
try:
resp = urllib.request.urlopen(req, timeout=3)
except urllib.HTTPError as e:
logging.warn("server process request error: err_code=%s", e.code)
return -5, None
except urllib.URLError as e:
logging.warn("reach server error: reason=%s", e.reason)
return -10, None
except Exception as e:
logging.warn("other exception: msg=%s", e.message)
return -100, None
htm = resp.read()
return 0, htm
评论列表
文章目录