Created
March 6, 2024 09:54
-
-
Save cd060/44f787ff66f0e036c4500a460980ed38 to your computer and use it in GitHub Desktop.
takes a VIAF ID as argument and returns the link to GND dataset
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 | |
import json | |
def get_gnd_from_viaf(viafid): | |
url = f'https://www.viaf.org/viaf/{viafid}/viaf.jsonld' | |
response = requests.get(url) | |
if response.status_code == 200: | |
data = response.json() | |
if "@graph" in data: | |
for entry in data["@graph"]: | |
if "@type" in entry and entry["@type"] == "schema:Person": | |
if "sameAs" in entry: | |
for s in entry["sameAs"]: | |
if s.startswith('http://d-nb.info/gnd') == True: | |
gnd=s | |
# print(s) | |
return gnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment