Dbpedia json extract

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

+4
source share
1 answer

You can get JSON without having to create custom headers with simpy requesting

If you are only interested in the rdfs:label object, you can request the endpoint using the 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 matches the request

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

SPARQL Results

which generates 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" }} ] } } 
+10
source

Source: https://habr.com/ru/post/1492391/


All Articles