You might be able to get what you want by selecting properties and objects where the property IRI begins with something you're interested in (e.g., http://dbpedia.org/ontology/). You could use a query like the following. (It takes advantage of the fact that a prefix by itself, e.g., dbpedia-owl:, is still a legal IRI, and you can use str on it. You could also just use the string http://dbpedia.org/ontology/
select ?p ?o where {
dbpedia:London ?p ?o
filter strstarts(str(?p),str(dbpedia-owl:))
}
SPARQL results (HTML Table)
SPARQL results (JSON)
The JSON results aren't quite in the format you're looking for, but are like this:
{ "head": { "link": [], "vars": ["p", "o"] },
"results": { "distinct": false, "ordered": true, "bindings": [
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "http://mapoflondon.uvic.ca/" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "http://www.british-history.ac.uk/place.aspx?region=1" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "http://www.london.gov.uk/" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "http://www.museumoflondon.org.uk/" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "http://www.tfl.gov.uk/" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "http://www.visitlondon.com/" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "https://london.gov.uk/" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageExternalLink" } , "o": { "type": "uri", "value": "http://www.britishpathe.com/workspace.php?id=2449&delete_record=75105/" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/thumbnail" } , "o": { "type": "uri", "value": "http://commons.wikimedia.org/wiki/Special:FilePath/Greater_London_collage_2013.png?width=300" }},
...
That sort of makes sense though, because there's not necessarily a unique value for each property, so a Python dict as in the question probably isn't the best result format (but it'd be easy to create one where multiple values are put into a list).
Also note that the properties that begin with dbpedia-owl: are actually the DBpedia Ontology properties, which have much cleaner data than the raw infobox values, for which properties beginning with dbpprop: are used. You can read more about the different datasets at 4.3. Infobox Data. A query for the raw properties would be pretty much the same though:
select ?p ?o where {
dbpedia:London ?p ?o
filter strstarts(str(?p),str(dbpprop:))
}
SPARQL Results (HTML Table)