Created
August 10, 2022 12:30
-
-
Save J535D165/fe976eddb871cf3ef84c016f723ddd82 to your computer and use it in GitHub Desktop.
Resolve the URL of the DOI
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 get_url_from_doi(doi): | |
"""Get the url from the DOI. | |
Arguments | |
--------- | |
doi: str | |
The DOI to find the url for. | |
Returns | |
------- | |
str: | |
The url. | |
""" | |
r = requests.head(f"https://doi.org/{doi}", allow_redirects=True) | |
return r.url | |
def test_url_retrieval(): | |
assert get_url_from_doi("10.34894/KEIQRD") == "https://dataverse.nl/dataset.xhtml?persistentId=doi:10.34894/KEIQRD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment