Select one specific index from array

Hi,

I'm a newbie in Node-RED. My first exercise is to scrap the HTML page and read the specific value in the table.

This is a government page that displays the river level in your city. Because they are not using a lot of CSS classes and IDs, the reading of the HTML table is difficult. The table also contains historical and unnecessary data, always wrapped in a td tag.

I was created HTML node with this selector: table.stdstationtbl>tr>td>div.center_text>table>tr>td

At the output, there is an array with indexes 0 - 115 but I need only one value - index no. 1. (see attached screenshot).

I tried to modify the selector as an example td[1] or (1) at the end, but in all cases, there is an error or empty response.

It is possible to select a specific (only one) value from an array? Or set n-th td tag in HTML (skip first two tags for example)?

I want to do not code functions.

Welcome to the forum.

You can use a Change node to Move msg.payload[1] into msg.payload.
Have a look at the node red docs page a Working with Messages which will give you help with that sort of thing.
In fact it would be a good idea to watch the Node-red Essentials videos linked from the docs.

1 Like

Thank you. It works. Now I have river level in Grafana.

1 Like

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