def _post(self, url, params, verbose=True):
return_raw = params.pop('return_raw', False)
headers = {'content-type': 'application/x-www-form-urlencoded',
'user-agent': "mygene.py/%s python-requests/%s" % (__version__, requests.__version__)}
res = requests.post(url, data=params, headers=headers)
from_cache = getattr(res, 'from_cache', False)
if self.raise_for_status:
# raise requests.exceptions.HTTPError if not 200
res.raise_for_status()
if return_raw:
return from_cache, res
ret = res.json()
return from_cache, ret
评论列表
文章目录