Created
May 26, 2016 12:55
-
-
Save halfak/7113348ab3496a3af3b7c2b2de14a526 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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