Module:SPARQL: Difference between revisions
From TITAF TANGOWIKI
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
local http = require("socket.http") | local http = require("socket.http") | ||
local function | local p = {} | ||
function p.fetchData(frame) | |||
local sparqlQuery = frame.args[1] | |||
local url = "https://query.wikidata.org/sparql?query=" .. mw.uri.encode(sparqlQuery, "PATH") | |||
local body, code, headers = http.request(url) | local body, code, headers = http.request(url) | ||
return body | |||
if code == 200 then | |||
return body | |||
else | |||
return "Error: HTTP " .. (code or "unknown") | |||
end | |||
end | end | ||
return | return p | ||
Revision as of 22:41, 21 March 2025
Documentation for this module may be created at Module:SPARQL/doc
local http = require("socket.http")
local p = {}
function p.fetchData(frame)
local sparqlQuery = frame.args[1]
local url = "https://query.wikidata.org/sparql?query=" .. mw.uri.encode(sparqlQuery, "PATH")
local body, code, headers = http.request(url)
if code == 200 then
return body
else
return "Error: HTTP " .. (code or "unknown")
end
end
return p