11.04.2023, 13:59
Great, but how do i split up the log to send the value i want?
I tried this code, it sends a value but not corectly. It first sends the value 5,6 310 times, then 13 other values once. At least all the values are from the correct table.
I tried this code, it sends a value but not corectly. It first sends the value 5,6 310 times, then 13 other values once. At least all the values are from the correct table.
Code:
url = 'https://www.havochvatten.se/badplatser-och-badvatten/vattenprov-badtemperatur/vattentemperatur-och-kvalitet-pa-badvatten-pa-sydkusten.html'
data = require('socket.http').request(url)
lines = data:split('\n')
for _, line in ipairs(lines) do
if line:find('<tr><td headers="head11">') then
location = line:match('<tr><td headers="head11">([^,]+)')
watertemp = tonumber(line:match('<td headers="head13">([^ ]+).+</td>'))
airtemp = tonumber(line:match('<td headers="head14">([^ ]+).+</td>'))
location = location:gsub('­', '')
log(location, watertemp, airtemp)
end
badtemp = watertemp
grp.write('10/5/101', badtemp)
end