Wait for page load before make Get request

I use http-request node with method GET, but the page takes a long time to finish loading, so it gives me a value of 0 where a larger number should go.
How could I solve it?

I don't understand what you mean. The request node should not pass on anything till it has the complete page.

I agree with Colin it shouldn’t pass anything on until the page completes. Unless it is timing out.

I would suggest putting a debug on the http request node to see what it is actually passing.

And paste that and your flow here

Is simple, inject + http request + debug

[{"id":"26e9db6e.00e074","type":"inject","z":"196c04a7.1fbc3b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":120,"wires":[["55c397f5.230f88"]]},{"id":"55c397f5.230f88","type":"http request","z":"196c04a7.1fbc3b","name":"","method":"GET","ret":"txt","url":"https://apsystemsema.com/ema/intoDemoUser.action?id=000000006661d922016663efb55a0188&locale=en_US","tls":"","x":430,"y":120,"wires":[["ffe64d19.9889b"]]},{"id":"ffe64d19.9889b","type":"html","z":"196c04a7.1fbc3b","name":"","property":"payload","outproperty":"payload","tag":"#today","ret":"html","as":"multi","x":590,"y":120,"wires":[["4bf7a7c4.585858"]]},{"id":"4bf7a7c4.585858","type":"debug","z":"196c04a7.1fbc3b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":120,"wires":[]}]

The page takes a couple of seconds to load its values

Your code isn't currently importable, you need to format it correctly in the forum. Please see this thread; How to share code or flow json

1 Like

Try loading the page in your web browser with javascript disabled/turned off ( look at the developer options)
Does that then match what Node-RED sees?

So, to fill in the missing details of your question, you make an HTTP Request of a page and then use an HTML node to find the element with id today to get its value.

When you load that page in your browser and View Source, you can see that element has a value of 0 - that is what Node-RED will get.

This is because the page uses javascript to dynamically change that value after the page has loaded. The HTTP Request node does not evaluate javascript when it retrieves a webpage - so any dynamically generated content will not be there.

You would need to dig deeper into how the page is loading the data you want, and then do the same with your Node-RED flow. You can use the browser developer tools to figure out what HTTP requests the page is making to the load the data dynamically.

1 Like

Thanks for your help, I will look how to work on it :slightly_smiling_face: