def get_doi_citeproc(doi):
"""
Use Content Negotioation (http://citation.crosscite.org/docs.html) to
retrieve the citeproc JSON citation for a DOI.
"""
url = 'https://doi.org/' + urllib.request.quote(doi)
header = {
'Accept': 'application/vnd.citationstyles.csl+json',
}
response = requests.get(url, headers=header)
try:
citeproc = response.json()
except Exception as error:
logging.error(f'Error fetching metadata for doi:{doi}.\n'
f'Invalid response from {response.url}:\n{response.text}')
raise error
citeproc['URL'] = f'https://doi.org/{doi}'
short_doi_url = get_short_doi_url(doi)
if short_doi_url:
citeproc['short_url'] = short_doi_url
return citeproc
评论列表
文章目录