Skip to content

Instantly share code, notes, and snippets.

@cd060
Created March 6, 2024 09:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cd060/44f787ff66f0e036c4500a460980ed38 to your computer and use it in GitHub Desktop.
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
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