Skip to content

Instantly share code, notes, and snippets.

@halfak
Created May 26, 2016 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halfak/7113348ab3496a3af3b7c2b2de14a526 to your computer and use it in GitHub Desktop.
Save halfak/7113348ab3496a3af3b7c2b2de14a526 to your computer and use it in GitHub Desktop.
import requests
def lookup_via_doidotorg(doi):
url = "http://doi.org"
data = {
"hdl": doi
}
response = requests.post(
url, data=data, headers={'Accept': "application/json"})
if response.status_code == 404:
raise RuntimeError("DOI not found")
elif response.status_code == 200:
return response.json()
else:
raise RuntimeError("Unknown error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment