Scrape sensor SMHI

Hi,

I need help with a scrape sensor. At first I thought it would be quite simple, but it is not, at least not to me who haven’t worked with web pages.

Maybe some Swedish person already did this and can help. I just want to scrape one simple piece of information out of a the Swedish Meteorological hydrological institute (SMHI) home page. What I want to scrape is the regional warnings (storms and floods and such stuff),(weather is my thing, I will have more questions about this later).

This is the link to the page I’m trying to scrape.
https://www.smhi.se/q/Stockholm/2673730

This is the info I’m trying to scrape (in the red oval), right now “inga varningar” (no warnings).

I have been trying to use the built in HA scraper to do this. I started by just doing inspect in the browser, when this didn’t work I installed the scraper add-on to chrome.
The scraper add-on give me the following to scrape, “wpt-keps-warning-p” and in chrome it catches the right info. I wanted to learn so I have been trying a lot of things, on and off for weeks, but failed.

Here is the inspect for warnings

Inga varningar utfärdade.

If you click the > you will get to another page that discplays the same thing. Maybe it is easier there?

Thanks for your help in advance.

BR
Tobe

The red oval isn’t in the picture I try again.

Don’t have a solution for this but maybe this is an alternative?

Hi Thanks,
I have that one installed, so far no problems. At least not with the integration or the card, the content is another story. The latest is about reporting food poisioning.

BR
Tobe

I also have some traffic scrapes from twitter.


  - platform: scrape
    name: Trafik P4 Stockholm
    resource: https://twitter.com/TrafikP4Sthlm
    select: ".js-tweet-text-container .tweet-text"
    
  - platform: scrape
    name: Kolletivtrafiken
    resource: https://twitter.com/kollektivkollen
    select: ".js-tweet-text-container .tweet-text"

The SMHI weather warning is the last thing I’m looking for.

Thanks
Tobe

The problem is that the part you are looking for is inside a <script>...</script> section.

This is not what you want? https://github.com/Lallassu/smhialert

Hi,

Found this after I posted, yes, I believe this is exactly what I want. Couldn’t instantly find the downloads and haven’t had the time to install it yet. But, it seems to be a much nicer solution than I was trying to achieve.

Best Regards
Tobe

Hi,

I now have the time to try it out, it works! Maybe a bit more info than I want. I tried to template it to just the warning and a link, but failed. I will see what to do, either cut it down to a warning or a flag that there is something to look at. The reason is, I tejped all my old useless (samsung/huawei) pads as control panels around the house, there is just not enough room on their screen. Maybe an indicator that something is cooking might also be ok.