Re: Querying dbpedia from the command line?

----- "Bob DuCharme" <bob@snee.com> 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. }"

You need to URLEncode the SPARQL query. I am not sure how to do that with a command-line or wget but that is what the browser has done to the query when it submitted the form using HTTP GET.

Cheers,

Peter

Received on Wednesday, 17 September 2008 01:02:00 UTC