def call_api(self):
url = 'http://prj2epsg.org/search.json?'
params = {
'mode': 'wkt',
'terms': self.prj
}
try:
req = request.urlopen(url+urlencode(params))
except request.HTTPError as http_exc:
logger.warning("""Failed to retrieve data from prj2epsg.org API:\n
Status: %s \n
Message: %s""" % (http_exc.code, http_exc.msg))
else:
raw_resp = req.read()
try:
resp = json.loads(raw_resp.decode('utf-8'))
except json.JSONDecodeError:
logger.warning('API call succeeded but response\
is not JSON: %s' % raw_resp)
self.process_api_result(resp)
评论列表
文章目录