Re: Querying dbpedia from the command line?


I'm not sure if it works on every SPARQL endpoint, but try this:

curl -F 'query=SELECT * WHERE { ?s ?p ?o } LIMIT 3'

The key is using curl's -F parameter (which takes a key-value pair and  
urlencodes the value), and putting the 'query=...' part into quotes.

(This uses HTTP POST instead of GET, so the query becomes not part of  
the URL as in the example you gave, but instead is sent in the body of  
the HTTP request.)


On 17 Sep 2008, at 01:51, Bob DuCharme wrote:

> Has anyone managed to pass a URL with a SPARQL query to wget or curl  
> and successfully retrieved data from dbpedia? When I take the wget  
> example at and  
> paste the query at dbpedia's SNORQL interface it works[1], and when  
> I paste the wget command on that page without any carriage returns  
> onto a (Windows) command line [2] it doesn't get any errors, which  
> certainly felt like a minor victory, but the result set was empty.
> Any suggestions?
> thanks,
> Bob
> [1]*+WHERE+ 
> {%0D%0A%3Fcity+db%3AleaderName+%3Fleader+%3B%0D%0Adb 
> %3AsubdivisionName+%3Fsubdiv+%3B%0D%0Adb%3Aelevation+%3Felevation+. 
> %0D%0A}+LIMIT+5
> [2] wget -O temp.txt"PREFIX  
> dbpedia2: <> PREFIX skos: < 
> > SELECT ?presName,?birthday, ?startDate WHERE {   ?presName  
> skos:subject < 
> >.   ?presName dbpedia2:birth ?birthday.   ?presName  
> dbpedia2:presidentStart ?startDate. }"

Received on Wednesday, 17 September 2008 14:59:31 UTC