如果我运行此SPARQL查询
#defaultView:BubbleChart
#TEMPLATE={"template":"Overall causes of death ranking of ?thing ","variables":{"?thing": {"query":"SELECT ?id (COUNT(?id) AS ?count) WHERE { ?sub wdt:P509 ?y. ?sub wdt:P31 ?id. } GROUP BY ?id "} } }
SELECT ?cid ?cause (COUNT(*) AS ?count) WHERE {
BIND(wd:Q5 AS ?thing)
?pid wdt:P31 ?thing.
?pid wdt:P509 ?cid.
OPTIONAL {
?cid rdfs:label ?cause.
FILTER((LANG(?cause)) = "en")
}
}
GROUP BY ?cid ?cause
ORDER BY DESC(?count) ?cause
LIMIT 50
在Wikidata Query Editor中,我可以选择使用菜单下载> SVG图像将气泡图下载为SVG文件
当我以编程方式执行相同的SPARQL脚本时,我正在寻找一种生成或检索此SVG文件的URL的方法 . 在这种情况下,仅返回原始数据(作为JSON) .
{“head”:{“vars”:[“cid”,“cause”,“count”]},“results”:{“bindings”:[{“cid”:{“type”:“uri”, “value”:“http://www.wikidata.org/entity/Q12152”},“cause”:{“xml:lang”:“en”,“type”:“literal”,“value”:“cardiac”梗塞“},”count“:{”datatype“:”http://www.w3.org/2001/XMLSchema#integer“,”type“:”literal“,”value“:”5837“}},{ “cid”:{“type”:“uri”,“value”:“http://www.wikidata.org/entity/Q12192”},“cause”:{“xml:lang”:“en”,“输入“:”literal“,”value“:”pneumonia“},”count“:{”datatype“:”http://www.w3.org/2001/XMLSchema#integer“,”type“:”literal“ ,“ Value ”:“2177”} ....等
1 回答
此SVG没有URL,因为它是在检索JSON结果后由浏览器中运行的Javascript生成的 . 如果你想以编程方式获得它,我认为使用浏览器自动化来运行Javascript代码并使用模拟用户操作获取文件将是实现它的最快方法 .