Extract HTML tag from website

Yesterday I discovered Node-RED and it seems it could help me to get data from a Salus IT500 thermostat so I try to extract a tag from thermostat page an i need a "token" that is in an <input> field and I need its value.
This is the input field:
<input id="token" type="hidden" value="XXXXXX-XXXXXXXXX" />
How can I get its value?

As long as you can grab the html content, you could use the html node. Some sites are generated by JS, and you may need to find an alternative route if this is the case.
example

[{"id":"97088f6a8ca79754","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"free | awk '/Mem/ {print $4}'","payloadType":"str","x":130,"y":660,"wires":[["55230f1f282d1489"]]},{"id":"55230f1f282d1489","type":"template","z":"da8a6ef0b3c9a5c8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head>\n        </head>\n        <body>\n            <input id=\"token\" type=\"hidden\" value=\"XXXXXX-XXXXXXXXX\" />\n            </body>\n            </html>","output":"str","x":260,"y":660,"wires":[["a6a6a5076ddacfc5"]]},{"id":"a6a6a5076ddacfc5","type":"html","z":"da8a6ef0b3c9a5c8","name":"","property":"payload","outproperty":"payload","tag":"input#token","ret":"attr","as":"single","x":430,"y":660,"wires":[["34d63e14690ac469"]]},{"id":"34d63e14690ac469","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 116","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":640,"wires":[]}]

output

[
  {
    "id":"token",
    "type":"hidden",
    "value":"XXXXXX-XXXXXXXXX"
  }
]

Thank you.
I did this:

[{"id":"fd54364bd77cbd0b","type":"http request","z":"06b6ca459f0d8b55","name":"","method":"GET","ret":"txt","paytoqs":"body","url":"https://salus-it500.com/public/control.php?devId=201450982","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"digest","senderr":false,"headers":[],"x":370,"y":80,"wires":[["8741321c644d0fcb"]]},{"id":"ef12537b53c8c073","type":"debug","z":"06b6ca459f0d8b55","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":80,"wires":[]},{"id":"cb0493ac07858bba","type":"inject","z":"06b6ca459f0d8b55","name":"Get Salus token","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"free | awk '/Mem/ {print $4}'","payloadType":"str","x":160,"y":80,"wires":[["fd54364bd77cbd0b"]]},{"id":"8741321c644d0fcb","type":"template","z":"06b6ca459f0d8b55","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n    <head>\n        </head>\n        <body>\n            <input id=\"token\" type=\"hidden\" value=\"\" />\n            </body>\n            </html>","output":"str","x":540,"y":80,"wires":[["b1bba4cb4bd0afd0"]]},{"id":"b1bba4cb4bd0afd0","type":"html","z":"06b6ca459f0d8b55","name":"","property":"payload","outproperty":"payload","tag":"input#token","ret":"attr","as":"single","x":710,"y":80,"wires":[["ef12537b53c8c073"]]}]

I deleted the X-es but it does not get me any token, only empty value
This is what I get:

Remove the template node, it is there in my example to create html to test the selector.
Also put a debug on the http request node and check what is returned.

This is without template node:

And this is what is returned from site:

It is not all data but this is site data where toke is located:

I did found some work on this Salus IT500 model done in Node-RED, but I hane no ideea how to import it:

The html you post is from the browser, not the request node. Send the debug to console, then you will see the return.

In the browser you are logged in, so you are not getting the landing page.
In the landing page is a form for logging in, you will need to recreate that form in a http request node, search the forum for example of how to post form. Then you will receive the correct html content holding your token.
https://discourse.nodered.org/search?expanded=true&q=http%20request%20post%20form

You should be able to install that node using the palette in the editor menu.

In the node I manage to make (before writting here) I log in and get all data that I need as a JSON but I wrote the token from page (page source). I need to get the token every time I connect since is changing at some interval. In the node you helped me to make I log in first and land on the device page so I supposed that I can get the token from there.

If I input an old token and an old timestamp, I get all needed data:


I will try to import that one since it gives me all the controls I need.
Thank you for all the help.

I managed to import that node.
Now I have work to do to understand how to use it...lol
Once again thank you for all the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.