Filtering Contents of a http get request

I am using Node-red v3.0.2
I am trying to extract temperatur from a wether webpage by using the http request node.
As response i get the html contant of the webpage and i just want to filter out the data wich is inside of a div container.

You need to use your browser's dev tools, go to the Elements tab and click on the Inspect button - looks like this for MS Edge:
image

Select the element on screen that you want to capture

At the bottom of that window, you should then see a a full path to the object. But you can right-click on the selected line in the code that is shown and select Copy > Selector.

You should be able to put that into the selector in the request node in order to get just the value you need. Here is an example from the Discourse page I'm typing into: #ember873 > div > div > div > span > button > svg.

You might need to try a higher-level element first and tweak things. For example from above, a selector of #ember873 should return a div containing the selected element and its surroundings. It can be a bit of a trial and error process to get what you need.

Also note though that some pages produce content dynamically via JavaScript scripts. If that is the case for the data you want, you will have to do something different since the request node does not have the ability to run JS on the page.

Thank you for your answer but i dont really understand what you mean by "the selector in the request node"
Also i looked if it can read the numbers and it can so its nothing JS related.

https://cookbook.nodered.org/http/simple-get-request

Use the css selector node to filter out as shown in the example in the link.

1 Like

Thanks for the answer

Yes, you need the html node to do the filter:

1 Like

The data on wetter.de comes from an API, you can directly pull this data.
Right click on the webpage > inspect element, go to the network tab, clear everything (trashcan).

Use search box to search for your location, you will see many requests coming in, a couple are called "current-conditions", those are JSON responses, check the header tab, the link you can directly call from node-red.

2 Likes

Thanks for the answer. I have already looked in to the network tab but there where so many responses. I will try it later

I have looked it up but i dont know wich one to use because each of them is different from the webpage.

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