topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday April 15, 2024, 11:37 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: [SOLVED VIA WORK AROUND] Get warnings from SMHI to text  (Read 3405 times)

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
On this page the Swedish weather service is presenting weather warnings.
https://www.smhi.se/...age=wpt-warning-alla
(I could not find an API to get the information from).

I want to be able to run something like this and get the respons in plain text, and be able to send the output to a text file.
C:\> SMHIvarning.exe https://www.smhi.se/...age=wpt-warning-alla
"Inga varningar i Västmanlands län"

Or change to this that at the time of writing have a forrest fire warning
C:\> SMHIvarning.exe https://www.smhi.se/...age=wpt-warning-alla
"RISK SKOGSBRAND Kronobergs län, västra delen"

Or this that at the time of writing have a class one storm warning
C:\> SMHIvarning.exe https://www.smhi.se/...age=wpt-warning-alla
"VARNING KLASS 1 KULING Bottenviken"

Notice that the "district" in the url changes
Picture also provided to give information.
SMHI1.png[SOLVED VIA WORK AROUND] Get warnings from SMHI to text

I will put the text togehter with my other scripts as shown in this picture.
smhi2.png[SOLVED VIA WORK AROUND] Get warnings from SMHI to text
smhi3.png[SOLVED VIA WORK AROUND] Get warnings from SMHI to text

With the output from C:\> SMHIvarning.exe https://www.smhi.se/...age=wpt-warning-alla > SMHIvastmanland.txt
i will use this "code" this is the way most of the output in above picture is created.
<code>
Echo |set /p=Varningar:
Type SMHIvastmanland.txt
</code>

Translations:
"Inga varningar i Västmanlands län" = "No warnings in Västmanlands län"
VARNING KLASS 1 KULING = "Warning class 1 gale"
RISK SKOGSBRAND "Risk Forest fire"

« Last Edit: June 25, 2021, 03:20 PM by user45454 »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
Re: IDEA: Get warnings from SMHI to text
« Reply #1 on: June 13, 2021, 06:41 PM »
I'm in! :)
My name's Victor but do feel free to call me Vic! (now known as "paradisusvic")

❤️ Support on Patreon @ www.patreon.com/paradisusis
New Email/Paypal: paradisusvicgmail.com

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
Re: IDEA: Get warnings from SMHI to text
« Reply #2 on: June 15, 2021, 05:59 PM »
I'm in! :)
-publicdomain (June 13, 2021, 06:41 PM)

I found an API - https://opendata-dow...rsion/2/messages.xml
Using Cygwin and below code.

<code>
   Curl  https://opendata-dow...rsion/2/messages.xml > eldrisk1.txt
   if DIFF -s eldrisk1.txt eldrisk1b.txt; then exit;
   fi
   cat eldrisk1.txt | egrep -i "<(text)>" | sed -e 's/<[^>]*>//g' -e 's/^[ \t]*//g' > eldrisk2.txt

   if test -s eldrisk2.txt; then
   iconv -f UTF-8 -t ISO-8859-15 eldrisk2.txt > eldrisk3.txt
   else
   echo "Ingen eldvarning utfärdad" > eldrisk3.txt
   fi
   cp eldrisk1.txt eldrisk1b.txt
</code>

This gives me
"Risken för bränder i skog och mark är stor eller mycket stor på flera håll i Götaland, Sörmland och Hälsingland"
(It says "Risk of fires in forest and ground is big or very big in several places in Götaland, Sörmland and Hälsingland)

There is another API with more info here: https://opendata-dow...version/2/alerts.xml

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
Re: IDEA: Get warnings from SMHI to text
« Reply #3 on: June 16, 2021, 09:08 AM »
Thanks for the extended reply with alternative API.

I'm finishing some programs for community release right now + exploring these APIs for yours :Thmbsup:

Stay tuned!
Vic
My name's Victor but do feel free to call me Vic! (now known as "paradisusvic")

❤️ Support on Patreon @ www.patreon.com/paradisusis
New Email/Paypal: paradisusvicgmail.com

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
Re: [SOLVED VIA WORK AROUND] Get warnings from SMHI to text
« Reply #4 on: June 25, 2021, 03:24 PM »
I managed to get this solved via the API and a bit of Cygwin.
Feel free to continue the work, but for me im happy with the result as I have it.