def _get(self, url, params={}, none_on_404=False, verbose=True):
debug = params.pop('debug_get', False)
return_raw = params.pop('return_raw', False)
headers = {'user-agent': "mygene.py/%s python-requests/%s" % (__version__, requests.__version__)}
res = requests.get(url, params=params, headers=headers)
from_cache = getattr(res, 'from_cache', False)
if debug:
return from_cache, res
if none_on_404 and res.status_code == 404:
return from_cache, None
if self.raise_for_status:
# raise requests.exceptions.HTTPError if not 200
res.raise_for_status()
if return_raw:
return from_cache, res.text
ret = res.json()
return from_cache, ret
评论列表
文章目录