我有这个SPARQL query in python
sparql = SPARQLWrapper("http://dbpedia.org/sparql",returnFormat="json")
sparql.setQuery('''
SELECT DISTINCT *
where {
[] foaf:isPrimaryTopicOf ?wikiID.
FILTER (regex(?wikiID, "(\\W|^)World(\\W|$)","i")) .
}
ORDER BY ?wikiID
limit 50
''')
queryResult = sparql.query().convert()
print json.dumps (queryResult, indent= 2, separators=(',',':'))但没有结果。
(SPARQLWrapper.SPARQLExceptions.QueryBadFormed:
QueryBadFormed: a bad request has been sent to the endpoint,
probably the sparql query is bad formed)在http://dbpedia.org/sparql上,查询是确定的,错误在哪里?
发布于 2015-01-12 18:38:28
这就是解决办法
sparql.method = 'GET'
sparql.setQuery('''
SELECT DISTINCT *
FROM <http://dbpedia.org>
where {
[] foaf:isPrimaryTopicOf ?wikiID.
FILTER (regex(?wikiID, "(\\\W|^)World(\\\W|$)")) .
}
ORDER BY ?wikiID
limit 50
''')https://stackoverflow.com/questions/27901254
复制相似问题