Hi all, I'm trying to use the tutorial on the wiki for lure to get output from a webpage, but it looks like the wiki page is outdated, and there doesn't appear to be any up to date tutorials or documentation for the later versions of lure (like the one from the github).
I essentially just need to read a string of text from a webpage, something like this:
Got what I needed with the following, just incase anyone else wants it. Please note, it is blocking, my next step is to figure out how to make it non-blocking, but for the game I'm developing, it's not too much of an issue.
http = require("socket.http")
ltn12 = require("ltn12")
function request(urlget)
local result_table = {}
client,r,c,h = http.request{
url = urlget,
sink = ltn12.sink.table(result_table)}
local result = table.concat(result_table)
return result
end
function love.load()
b = request("http://www.themeq.xyz/ethereal/api.php")
a = "Hello"
if a == b then
print("Matched!")
else
print("Not Matched!")
end
print(b)
end
These are the two relevant files. My utils.request is like your http wrapper thing. and in Todo.lua all I do is require async and add the requests as jobs. When you require async it will pass around one instance. So you do not need to worry about it being a global.