# Get data from a homepage

**URL:** <https://discourse.nodered.org/t/get-data-from-a-homepage/66421>\
**Category:** General\
**Created:** [14 August 2022 13:52 UTC](https://discourse.nodered.org/t/get-data-from-a-homepage/66421 "2022-08-14T13:52:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [14 August 2022 13:52 UTC](https://discourse.nodered.org/t/get-data-from-a-homepage/66421/1 "2022-08-14T13:52:22Z")

</div>

Hello  
from

> **[MeteoSchweiz](https://www.meteoschweiz.admin.ch/home.html?tab=temperature)**
>
> MeteoSchweiz erbringt im Auftrag des Bundes verschiedene Wetter- und Klimadienstleistungen zum Schutz und zum Nutzen der Schweiz.

i would like to collect the 3 altitude "Nullgradgrenze"

so from the   
i have a html node and the Selektor is  
table.table\_simple heights-table

i would expect some output but got just nothing - so what do i wrong?  
Could the problem be the space between table\_simple heights-table?

```auto
[
    {
        "id": "36240c5e5341146e",
        "type": "inject",
        "z": "d753f1f6adf829e0",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 240,
        "y": 3060,
        "wires": [
            [
                "cb6935655871fe12"
            ]
        ]
    },
    {
        "id": "f3a54f2556d33c09",
        "type": "html",
        "z": "d753f1f6adf829e0",
        "name": "",
        "property": "payload",
        "outproperty": "payload",
        "tag": "table.table_simple heights-table",
        "ret": "html",
        "as": "multi",
        "x": 790,
        "y": 3060,
        "wires": [
            [
                "8c398d9d94eafc32"
            ]
        ]
    },
    {
        "id": "cb6935655871fe12",
        "type": "http request",
        "z": "d753f1f6adf829e0",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://www.meteoschweiz.admin.ch/home.html?tab=temperature",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 490,
        "y": 3060,
        "wires": [
            [
                "f3a54f2556d33c09"
            ]
        ]
    },
    {
        "id": "8c398d9d94eafc32",
        "type": "debug",
        "z": "d753f1f6adf829e0",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 3100,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [14 August 2022 14:17 UTC](https://discourse.nodered.org/t/get-data-from-a-homepage/66421/2 "2022-08-14T14:17:00Z")

</div>

While testing something like this, the first thing I do is add a `write file` node and dump the data from the `http request` to a file on my device.

`inject -> write file`

This allows you to then use a `read file` node to get the page without sending multiple requests to the server and - possible - gettng you banned as a spammer.

`inject -> read file -> html -> debug`

you can also use a text editor to look at th html, search for "Nullgradgrenze" to see how to address it.

In addition, it looks like this page is filled by some of the scripts that are built into it. You are going to follow them too

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 August 2022 14:35 UTC](https://discourse.nodered.org/t/get-data-from-a-homepage/66421/3 "2022-08-14T14:35:29Z")

</div>

The values you want are likely populated by script from a separate JSON request. Open your browsers devtools, refresh the page while looking at the "network" tab - you will see `json` data requests - what you are looking for will likely be inside one of those...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af48f3fae52232fe1b87758a769e2d5561f365de.png)

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [14 August 2022 14:58 UTC](https://discourse.nodered.org/t/get-data-from-a-homepage/66421/4 "2022-08-14T14:58:42Z")

</div>

@Steve-Mcl it worked - but the server don't like it - access denied after a couple of time. then the path to the json file  
[https://www.meteoschweiz.admin.ch/product/output/altitude-levels/version\_\_20220814\_1431/heights\_temperature\_de.json](https://www.meteoschweiz.admin.ch/product/output/altitude-levels/version__20220814_1431/heights_temperature_de.json)

has a version with a time stamp ;-(

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [14 August 2022 16:10 UTC](https://discourse.nodered.org/t/get-data-from-a-homepage/66421/5 "2022-08-14T16:10:34Z")

</div>

You can try two requests in sequence .. one to get the valid json url path and the second request to the actual file

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4fc92330ee38b8fd718ce592eedb67abae3a6953.png)

Demo Flow:

```auto
[{"id":"36240c5e5341146e","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":4360,"wires":[["f9b2a0a4d11f74ef"]]},{"id":"cb6935655871fe12","type":"http request","z":"54efb553244c241f","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":950,"y":4380,"wires":[["8c398d9d94eafc32"]]},{"id":"8c398d9d94eafc32","type":"debug","z":"54efb553244c241f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":4380,"wires":[]},{"id":"f9b2a0a4d11f74ef","type":"http request","z":"54efb553244c241f","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.meteoschweiz.admin.ch/home.html?tab=temperature","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":330,"y":4360,"wires":[["24a06e3c3958cf59"]]},{"id":"246ae5ad2bab3f4a","type":"debug","z":"54efb553244c241f","name":"debug 17","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":780,"y":4480,"wires":[]},{"id":"49971f9af646b89d","type":"function","z":"54efb553244c241f","name":"function","func":"let jsonUrl = msg.payload[0][\"data-json-url\"]\n\nmsg.url = \"https://www.meteoschweiz.admin.ch\" + jsonUrl;\n\nmsg.headers = {\n \"Accept\": \"application/json, text/javascript, */*; q=0.01\",\n \"X-Requested-With\": \"XMLHttpRequest\",\n \"Referer\": \"https://www.meteoschweiz.admin.ch/home.html?tab=temperature\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":4380,"wires":[["dc96e67f1d8bc840","cb6935655871fe12"]]},{"id":"24a06e3c3958cf59","type":"html","z":"54efb553244c241f","name":"","property":"payload","outproperty":"payload","tag":".temperature__heights","ret":"attr","as":"single","x":560,"y":4380,"wires":[["246ae5ad2bab3f4a","49971f9af646b89d"]]},{"id":"dc96e67f1d8bc840","type":"debug","z":"54efb553244c241f","name":"debug 18","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":4280,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 October 2022 16:11 UTC](https://discourse.nodered.org/t/get-data-from-a-homepage/66421/6 "2022-10-13T16:11:28Z")

</div>

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