1

I want to extract some text of Wikipedia as JSON, using SPARQL. The following query retrieves the text, but in HTML format. How can I get the JSON output?

# -*- coding: utf-8 -*-

from SPARQLWrapper import SPARQLWrapper, JSON
from pprint import pprint 


sparqlwiki = SPARQLWrapper("https://en.wikipedia.org/wiki/Saket_Modi")

sparqlwiki.setReturnFormat(JSON)
resultswiki = sparqlwiki.query().convert()
from pprint import pprint
pprint(resultswiki)

output of above code can be found here

Nitin
  • 11
  • 3
  • What is the actual result that you get back? You say that it's HTML, but what is the actual value? I don't know what **pprint** does for you--what is the actual value of `resultswiki`? – Joshua Taylor May 26 '16 at 15:43
  • 4
    How can you use SPARQL to query a Wikipedia HTML page? SPARQLWrapper expects a SPARQL endpoint URL. And what is the default query? I'm pretty sure that this does not work. What would be the magic behind using SPARQL on text? – UninformedUser May 26 '16 at 16:21
  • Why are you sending query to `https://en.wikipedia.org/wiki/Saket_Modi` ? Wouldn't running a sparql query against DBPEDIA make a lot more sense? – Joshua Taylor May 26 '16 at 22:57

0 Answers0