Skip to content

Instantly share code, notes, and snippets.

@jrsmith3
Last active January 5, 2024 09:17
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jrsmith3/5513926 to your computer and use it in GitHub Desktop.
Save jrsmith3/5513926 to your computer and use it in GitHub Desktop.
Python method to access crossref.org DOI bibtex metadata resolver
import requests
def doi2bib(doi):
"""
Return a bibTeX string of metadata for a given DOI.
"""
url = "http://dx.doi.org/" + doi
headers = {"accept": "application/x-bibtex"}
r = requests.get(url, headers = headers)
return r.text
@johnro
Copy link

johnro commented Mar 5, 2015

Great! This saved me lots of headache ! :)

@marekborowiec
Copy link

The most useful six lines of code I've seen in a long time. Thanks!

@GabrielFonsecaGuerra
Copy link

Awesome!!! .. truly thank you

@aFelipeSP
Copy link

can you explain it please, I would be very thankful

@myeghaneh
Copy link

thank you for the code, could you please how can I download entire file of DOI in zenobi using python, imagine this file

https://zenodo.org/record/3269732#.XVGJJehKhaS

how can I download the entire file. many thanks

@abrefael
Copy link

That's great!!
thank you!
I would change this a little to accommodate for easier copy-paste that may include the whole http://dx.doi.org/ url:

def doi2bib(doi):
...if "http://dx.doi.org/" not in doi:`
......doi = "http://dx.doi.org/" + doi
...headers = {"accept": "application/x-bibtex"}
...r = requests.get(doi, headers = headers)
...return r.text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment