def _do_post(self, url, data, headers):
try: # Python 3
if data != None:
data = bytes(data, 'utf-8')
except: # Python 2
pass
try:
req = url_request.Request(url=url, data=data, headers=headers)
req.add_header('User-Agent', KKBOXHTTP.USER_AGENT)
f = url_request.urlopen(req)
r = f.read()
except url_request.HTTPError as e:
print(e.fp.read())
raise (e)
except Exception as e:
raise (e)
try: # Python 3
r = str(r, 'utf-8')
except: # Python 2
pass
json_object = json.loads(r)
return json_object
评论列表
文章目录