Created
February 21, 2017 23:12
-
-
Save cuevasclemente/551bfd48b15347c307d64368d7ef959f to your computer and use it in GitHub Desktop.
Runs a sparql query on dbpedia
This file contains hidden or 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
#!/bin/env python3 | |
## usage: ./sparql_query.py 'select ?x where {[] a ?x} limit 100' | |
import json | |
import sys | |
from SPARQLWrapper import SPARQLWrapper, JSON | |
if __name__ == '__main__': | |
query = sys.argv[1] | |
sparql = SPARQLWrapper('http://dbpedia.org/sparql') | |
sparql.setQuery(query) | |
sparql.setReturnFormat(JSON) | |
print(json.dumps(sparql.query().convert())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment