This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Get temperature data from web page
#4
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.

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('&#xAD;', '')

    log(location, watertemp, airtemp)
  end
badtemp = watertemp
grp.write('10/5/101', badtemp)
end


   

   
Reply


Messages In This Thread
RE: Get temperature data from web page - by Ohmarn - 11.04.2023, 13:59

Forum Jump: