Using node red to check if item is in stock?

Is there a way to get node red to check a webpage and alert me when its in stock?

I tried first just doing an http request and it does return a payload, but it appears to be truncated. I need to see the entire payload and then hoping I can put in a switch to look for the words out of stock.

How do I get the payload to not be truncated?

[{"id":"5b052fc3.25283","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"a404705e.d925","type":"inject","z":"5b052fc3.25283","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1312,"y":153,"wires":[["f382423a.cf469"]]},{"id":"f382423a.cf469","type":"http request","z":"5b052fc3.25283","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1304,"y":225,"wires":[["b68fe543.a67b08"]]},{"id":"b68fe543.a67b08","type":"debug","z":"5b052fc3.25283","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1301,"y":297,"wires":[]}]

Depends on the page.

Some pages like that are updated dynamically by JavaScript AFTER the page has been returned to the browser. In that case, a simple request node will not work and you would have to use a full "headless browser" node.

As stated in the Node-RED docs, the debug output is truncated if it gets too long so that performance of the browser isn't badly impacted.

You need to use something like the html node to select just a part of the returned content.

The best approach is to open the page in your browser and use the developer tools to select the area of html that you want. Then you can copy the selector which you can use in the html node.

However, just watch out for the page updating itself from JavaScript after it has loaded, this is really common for information that is quite dynamic. It lets the authors of the site quickly deliver the more static information and then enrich the page with dynamic data afterwards.

The payload isn't truncated, it is just the view in the debug pane that is truncated. If you set the debug node to also send to the console then the full payload should appear in the log.

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