如果我运行此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
Run Code Online (Sandbox Code Playgroud)
在维基数据查询编辑器中,我可以选择使用菜单下载> SVG图像将气泡图下载为SVG文件
当我以编程方式执行相同的SPARQL脚本时,我正在寻找一种生成或检索此SVG文件的URL的方法.在这种情况下,仅返回原始数据(作为JSON).
{"head":{"vars":["cid","cause","count"]},"results":{"bindings":[{"cid":{"type":"uri","值":" http://www.wikidata.org/entity/Q12152 "},"原因":{"xml:lang":"en","type":"literal","value":"心肌梗塞"},"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","type" ":"literal","value":"pneumonia"},"count":{"datatype":" http://www.w3.org/2001/XMLSchema#integer ","type":"literal", "价值":"2177"} ......等
该 SVG 没有 URL,因为它是由浏览器中运行的 Javascript 在检索 JSON 结果后生成的。如果您想以编程方式获取它,我认为使用浏览器自动化来运行 Javascript 代码并使用模拟用户操作获取文件将是实现它的最快方法。