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.

Help to read html code
#3
(22.11.2019, 00:06)Erwin van der Zwart Wrote: Hi,

Try this:
Code:
require('socket.http')
socket.http.TIMEOUT = 5
data = socket.http.request('http://192.168.1.238/en/phase1.html')

-- Check if response value is received
if data then
  -- Fetch values from HTTP response
  p_activa = data:match([[<td id="p_activa">(.-)</td>]])
  -- Remove units and trims leading and trailing spaces and decode to numberic
  p_activa = tonumber(string.trim(string.gsub(p_activa, "W", "", 1)))
  -- Write to KMX
  grp.write('1/1/1', p_activa)
end
BR,

Erwin
Hello @Erwin van der Zwart
Thanks for the script!!
I change the script in order to put the user and password and to change the output object (virtual byte floating point) see it:

Code:
require('socket.http')
socket.http.TIMEOUT = 5
data = socket.http.request('http://user:user@192.168.1.238/en/phase1.html')
log(data)

-- Check if response value is received
if data then
  -- Fetch values from HTTP response
  p_activa = data:match([[<td id="p_activa">(.-)</td>]])
  log(p_activa)
  -- Remove units and trims leading and trailing spaces and decode to numberic
  p_activa = tonumber(string.trim(string.gsub(p_activa, "W", "", 1)))
  log(p_activa)
  -- Write to KMX
  grp.write('32/3/1', p_activa)
end

But this doesn't work, looking to the log this is the output:

[Image: log.png]

And this is the searched data read from the wibeee webpage, storeged on "data"

Code:
<tr>
     <td>Active Power</td>
     <td id="p_activa"></td>
</tr>

Any idea?

Thanks again.
Reply


Messages In This Thread
Help to read html code - by peyoe - 21.11.2019, 22:13
RE: Help to read html code - by peyoe - 22.11.2019, 08:01
RE: Help to read html code - by admin - 22.11.2019, 08:04
RE: Help to read html code - by peyoe - 22.11.2019, 08:35
RE: Help to read html code - by admin - 22.11.2019, 09:03
RE: Help to read html code - by peyoe - 22.11.2019, 09:30
RE: Help to read html code - by Daniel - 22.11.2019, 09:57
RE: Help to read html code - by peyoe - 22.11.2019, 10:22
RE: Help to read html code - by peyoe - 22.11.2019, 15:07
RE: Help to read html code - by Daniel - 22.11.2019, 15:15
RE: Help to read html code - by peyoe - 22.11.2019, 15:30
RE: Help to read html code - by peyoe - 25.11.2019, 12:30
RE: Help to read html code - by Joep - 14.12.2019, 15:09

Forum Jump: