Re: Querying dbpedia from the command line?

> ----- "Bob DuCharme" <> wrote:
>> Has anyone managed to pass a URL with a SPARQL query to wget or curl
>> and successfully retrieved data from dbpedia? 

 > Peter Ansell wrote:

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

I had tried several variations on that. (First I realized that [2] in my 
original email had the wrong URL; it should have said the following, 
without carriage returns:)

wget -O temp.txt"PREFIX 
db:<> SELECT * WHERE { ?city db:leaderName 
?leader ; db:subdivisionName ?subdiv ; db:elevation ?elevation . } LIMIT 5"

Using the very handy escape/unescape page at, I 
made this escaped version

wget -O temp.txt*%20WHERE%20%7B%20%3Fcity%20db%3AleaderName%20%3Fleader%20%3B%20db%3AsubdivisionName%20%3Fsubdiv%20%3B%20db%3Aelevation%20%3Felevation%20.%20%7D%20LIMIT%205%22

and when trying to run it I just get error messages whether I quoted the 
URL, put the line in a batch file and tried it from there... (At least 
the unescaped version gave me well-formed XML as a response, even if the 
result set was empty.)

After trying several more combinations of escaped vs. unescaped, wget 
vs. curl, quoting vs. not quoting, Windows vs. Linux, and using the 
command directly from the command line vs. putting it in a batch file or 
shell script and calling that, I just got it to work calling the 
unescaped version with wget from a shell script on a Linux box.

I'd still like to hear about any luck others might have had.


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