In [1]:
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
In [2]:
sparql.setQuery("""
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label
WHERE { <http://dbpedia.org/resource/Asturias> rdfs:label ?label }
""")
In [3]:
sparql.setReturnFormat(JSON)
In [4]:
results = sparql.query().convert()
In [5]:
for result in results["results"]["bindings"]:
print(result["label"]["value"])
In [ ]: