Re: Querying dbpedia from the command line?

Bob,

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

curl -F 'query=SELECT * WHERE { ?s ?p ?o } LIMIT 3' http://dbpedia.org/sparql

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.)

Best,
Richard


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 http://groups.yahoo.com/group/govtrack/message/570 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] http://dbpedia.org/snorql/?query=PREFIX+db%3A%0D%0A%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0D%0ASELECT+*+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 http://DBpedia.org/sparql?query="PREFIX  
> dbpedia2: <http://dbpedia.org/property/> PREFIX skos: <http://www.w3.org/2004/02/skos/core# 
> > SELECT ?presName,?birthday, ?startDate WHERE {   ?presName  
> skos:subject <http://dbpedia.org/resource/Category:Presidents_of_the_United_States 
> >.   ?presName dbpedia2:birth ?birthday.   ?presName  
> dbpedia2:presidentStart ?startDate. }"
>

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