5
votes

http://dbpedia.org/resource/Los_Angeles
You can request this data programmatically in many formats by using the appropriate header in your HTTP request.
For example "Accept: application/json" will get you the results in JSON.
1. How do I go about retrieving the JSON
2. Since I have to filter only
a class="uri" href="http://www.w3.org/2000/01/rdf-schema#label"
for around 100 links on my page. What is the best way around it

1

1 Answers

10
votes

You can retrieve the JSON without having to create special headers by simpy requesting

If you're only interested in the rdfs:labels of the entity, you might query the endpoint by using a template request URL:

http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=select*%7Bdbpedia%3ALos_Angeles+rdfs%3Alabel+%3Flabel%7D&format=json

which corresponds to the query

select*{dbpedia:Los_Angeles rdfs:label ?label}

SPARQL results

which generates the JSON:

{ "head": { "link": [], "vars": ["label"] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "label": { "type": "literal", "xml:lang": "uk", "value": "\u041B\u043E\u0441-\u0410\u043D\u0434\u0436\u0435\u043B\u0435\u0441" }},
    { "label": { "type": "literal", "xml:lang": "vi", "value": "Los Angeles" }},
    { "label": { "type": "literal", "xml:lang": "zh", "value": "\u6D1B\u6749\u77F6" }},
    { "label": { "type": "literal", "xml:lang": "ca", "value": "Los Angeles" }},
    { "label": { "type": "literal", "xml:lang": "cs", "value": "Los Angeles" }},
    { "label": { "type": "literal", "xml:lang": "de", "value": "Los Angeles" }},
    { "label": { "type": "literal", "xml:lang": "en", "value": "Los Angeles" }} ] } }