Skip to content

Instantly share code, notes, and snippets.

@jindrichmynarz
Last active November 16, 2018 14:36
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 jindrichmynarz/a947af0712682e0d23584719f0b6b400 to your computer and use it in GitHub Desktop.
Save jindrichmynarz/a947af0712682e0d23584719f0b6b400 to your computer and use it in GitHub Desktop.
SPARQL: It's just HTTP!
#!/usr/bin/env python
import urllib
from rdflib import Graph
def main():
endpoint = "https://query.wikidata.org/sparql"
query = """
CONSTRUCT WHERE {
?s ?p ?o .
}
LIMIT 10
"""
url = endpoint + "?" + urllib.urlencode({"query": query})
g = Graph()
g.parse(url)
print(g.serialize(format = "n3"))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment