topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Saturday December 7, 2024, 5:17 am
  • 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

Last post Author Topic: [IDEA] Display the weather in the command line (Weather forcast to text)  (Read 19256 times)

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
What I want: To display the weather from www.klart.se in the command line.

From this page https://www.klart.se...4der-alberga/timmar/
I want a program that gets the today weather forcast part (part marked in screen shot 1) and saves it to a textfile so it can be typed into into a command line window, or directly types it into the command line window (see screen shot 2).
Note that I changed some tittles in the command line version.
The text on the webpage is in Swedish, I hope it is not a problem.

Picture1.png[IDEA] Display the weather in the command line (Weather forcast to text)Picture2.png[IDEA] Display the weather in the command line (Weather forcast to text)
« Last Edit: January 18, 2022, 03:45 PM by user45454 »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
What I want: To display the weather from www.klart.se in the command line.

From this page https://www.klart.se...4der-alberga/timmar/

Hi! I'm currently finishing several "dangling" releases yet yours gets included as well since it's a 1-day code :)

https://github.com/p...main/weather-to-text
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

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,190
    • View Profile
    • Donate to Member
So, this isn't exactly what you asked for, but it was an interesting problem, so I did it anyway :)

It uses wttr.in (I couldn't figure out that other site- when I put in a location, it required a more specific name for the results page than I could figure out quickly).

It's in powershell, and I documented it in the comments. Save it to Get-Weather.ps1 and run it, i.e.

.\Get-Weather.ps1

It will prompt you for the city- you can specify it just by city and it will sometimes get it right from your location, but you can also use state/province/country, etc - just separate with ,. i.e.

.\Get-Weather.ps1
Enter name of the City to get weather report: Cairo

This would display the weather for Cairo,Egypt, but

.\Get-Weather.ps1
Enter name of the City to get weather report: Cairo,Illinois

Would display the weather for Cairo,Illinois

Code: PowerShell [Select]
  1. <#
  2. Get-Weather
  3.  
  4. Created in response to a request on DonationCoder
  5. - https://www.donationcoder.com/forum/index.php?topic=51394
  6.  
  7. Retrieves weather from http://wttr.in/ and prints it to commandline
  8.  
  9. Parameters:
  10. -City: [required] City to retrieve the weather for
  11. -IncludeTomorrow : Also include tomorrow's weather
  12. -IncludeNext2Days : Also include the weather for the next two days
  13.  
  14. #>
  15.  
  16. param (
  17.     [string]$City = $( Read-Host "Enter name of the City to get weather report" ),
  18.     [switch] $IncludeTomorrow,
  19.     [switch] $IncludeNext2Days
  20.     )
  21.  
  22. try {
  23.     $url = "http://wttr.in/$($City)"
  24.  
  25.     $Weather = $(Invoke-WebRequest $url –UserAgent curl).content -split "`n"
  26.  
  27.     if($Weather)
  28.     {
  29.         $Weather[0..16]
  30.         if(($IncludeTomorrow) -or ($IncludeNext2Days)){ $Weather[17..26] }
  31.         if($IncludeNext2Days){ $Weather[27..36] }
  32.     }
  33. }
  34. catch {
  35.     $_.exception.Message
  36. }

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
So, this isn't exactly what you asked for, but it was an interesting problem, so I did it anyway :)

Wowie!!! Thanks for your willingness to help a fellow!



Note that I changed some tittles in the command line version.

WeatherToText v0.1.0 is released: https://www.donation...ex.php?topic=51403.0

Text substitution comes @ v0.1.1

Please check what's there suits you Cheers!
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
« Last Edit: May 15, 2021, 08:05 AM by publicdomain »

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
So, this isn't exactly what you asked for, but it was an interesting problem, so I did it anyway :)

Wowie!!! Thanks for your willingness to help a fellow!



Note that I changed some tittles in the command line version.

WeatherToText v0.1.0 is released: https://www.donation...ex.php?topic=51403.0

Text substitution comes @ v0.1.1

Please check what's there suits you Cheers!
-publicdomain (May 15, 2021, 07:55 AM)

Verry nice but I get this error
"Error: The request was aborted: Could not create SSL/TLS secure channel."

 :o

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
"Error: The request was aborted: Could not create SSL/TLS secure channel."

Thanks for reporting, I tested it on Linux/Mono version 6.12.0.122 (.NET framework 4.5 compilation target).

Going to add text replacements & test it on Windows for patched v0.1.1 :Thmbsup: Cheers!

WeatherToText_v0-1-0.png[IDEA] Display the weather in the command line (Weather forcast to text)

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
« Last Edit: May 16, 2021, 03:01 AM by publicdomain »

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,190
    • View Profile
    • Donate to Member
I just realized looking at the source, I was reading too much into the request- you wanted that specific page, not a parameterized query from that site.

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
Fixed the cross-platform code from the report:

"Error: The request was aborted: Could not create SSL/TLS secure channel."

v0.1.1 has been released! :)

WeatherToText topic updated to reflect it: https://www.donation...ex.php?topic=51403.0

Tested on Windows & Linux. Both running:

WeatherToText_v0-1-1_Windows.png[IDEA] Display the weather in the command line (Weather forcast to text)

WeatherToText_v0-1-1_Linux.png[IDEA] Display the weather in the command line (Weather forcast to text)

Cheers! :Thmbsup:
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
« Last Edit: May 16, 2021, 03:32 AM by publicdomain »

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
Hi,

A short translation of what the Swedish words mean.


Tid=Time
Känns=Feels (känns som=feels like)
BY = Gust of wind (should say "vindby" because vind=wind)
Sannolikhet nederbörd =  Probability of precipitation
Sannolikhet åska = Probability of thunder
Soluppgång = Sun Rise
Solnedgång = Sun set

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
Fixed the cross-platform code from the report:

"Error: The request was aborted: Could not create SSL/TLS secure channel."

v0.1.1 has been released! :)

WeatherToText topic updated to reflect it: https://www.donation...ex.php?topic=51403.0

Tested on Windows & Linux. Both running:

Picture3.png[IDEA] Display the weather in the command line (Weather forcast to text)

[ Invalid Attachment ]

Cheers! :Thmbsup:
-publicdomain (May 16, 2021, 03:06 AM)

Things are really starting to take form.
Looking good :-)
Is it possible to make it look like picture provided?
No borders, removed "(by)" more compact with row separtion for "nederbörd" & "åska" and no letter "A" after the temp.
Picture3.png[IDEA] Display the weather in the command line (Weather forcast to text)

For future release
If the weather location could be made as an input like this
"WeatherToText.exe https://www.klart.se...4der-alberga/timmar/"
"WeatherToText.exe https://www.klart.se...4der-caracas/timmar/"
It would be usable for alot more people.

Right now it is hardcoded so the program is only usable for about the 100 people
that lives in my small town. :-)


wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,190
    • View Profile
    • Donate to Member
For future release
If the weather location could be made as an input like this
"WeatherToText.exe https://www.klart.se...4der-alberga/timmar/"
"WeatherToText.exe https://www.klart.se...4der-caracas/timmar/"
It would be usable for alot more people.


Yeah, this was what I was trying to do, but couldn't figure out the API for the urls, it being Swedish limited my ability to search. Your suggestion of sending in the URL is a good one!

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
Is it possible to make it look like picture provided?

Yes afirmar.gif

For future release [...]

Sure thing! :up:

I'm coding AppFolderIcon + a couple other proggies for the community simultaneously; this update is added to the flow of releases  :)

(Stay tuned! We're talking days only)
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
« Last Edit: May 19, 2021, 05:33 PM by publicdomain »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
WeatherToText v0.2.0 is out! porra.gif

Download + info: https://www.donationcoder.com/forum/index.php?topic=51403.0

Cross-platform:

WeatherToText_v0-2-0_screenshot_2.png[IDEA] Display the weather in the command line (Weather forcast to text)
Windows

WeatherToText_v0-2-0.png[IDEA] Display the weather in the command line (Weather forcast to text)
Linux

Enjoy! dedosarriba.png
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
« Last Edit: May 20, 2021, 07:13 AM by publicdomain »

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
WeatherToText v0.2.0 is out! [ Invalid Attachment ]

Download + info: https://www.donationcoder.com/forum/index.php?topic=51403.0

Cross-platform:

[ Invalid Attachment ]
Windows

[ Invalid Attachment ]
Linux

Enjoy! [ Invalid Attachment ]
Vic
-publicdomain (May 19, 2021, 05:16 PM)


This is looking real great now!  :up: :D

Just a few things.
Picture 1:Picture4.png[IDEA] Display the weather in the command line (Weather forcast to text)
1) You can see in the picture that I get an "Â" between the numer and the grade sign.
2) And the sunset is getting the "Å" letter wrong, "21:34 SolnedgÃ¥ng".
At the time of writing Sun rise is gone but I think sun rise aka "Soluppgång" was correct, "åska" and "nederbörd" is also working fine.


Picture2:Picture5.png[IDEA] Display the weather in the command line (Weather forcast to text)
1) I would  like to have the whole part that is in between the "()" removed.
See picture two what I mean.
2) It looks like the program forcing yellow ouput ?
We dont need to do that, some day we might want to change output color.
« Last Edit: May 21, 2021, 02:31 PM by user45454 »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
This is looking real great now!

Please check v0.3.0: https://www.donation....msg445163#msg445163

:Thmbsup:
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

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
This is looking real great now!

Please check v0.3.0: https://www.donation....msg445163#msg445163

:Thmbsup:
-publicdomain (June 10, 2021, 12:20 AM)


Could we add the option to load also tomorrows forcast ?
The data is on the same site to be read.
Im running this at home, reloading once an hour, works great!  :up:
But the later it gets the more I would like to see whats happens after midnight.

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
Could we add the option to load also tomorrows forcast ?

Yes, sure! :) What do you have in mind? Extra parameter added to the program? (i.e. for passing "tomorrow" as argument).

It can also be integrated into regular operation, perhaps having 24-hour data always displayed on screen (regardless of day boundaries).

Fell free to express! I'm here to code it :up:

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
Could we add the option to load also tomorrows forcast ?

Yes, sure! :) What do you have in mind? Extra parameter added to the program? (i.e. for passing "tomorrow" as argument).

It can also be integrated into regular operation, perhaps having 24-hour data always displayed on screen (regardless of day boundaries).

Fell free to express! I'm here to code it :up:

Vic
-publicdomain (June 19, 2021, 01:51 PM)

Is it possible to load the next comming day but only after a certain time ?
Im runnning this program 24/7 and realoading it once an hour.

Something like (or maybe not at all, but you understand)
C:\WeatherToText.exe /?
Displays the hourerly weather forcast for a given location from klart.se.

/N Display the next day forcast
/T Specifies at what time WeatherToText shall load the next day forcast

c:\WeatherToText.exe https://www.klart.se/se/södermanlands-län/väder-alberga/timmar/ yellow /N /T 1900
Would only start loading the next day when my clock is 19:00 or after (7 pm) and until 00:00, otherwise it would loop forever.

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
/N Display the next day forcast
/T Specifies at what time WeatherToText shall load the next day forcast

Sounds like a plan! :)

Added to the batch of releases to close the month :Thmbsup:
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

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
...Took a bit longer than expected! WeatherToText v0.4.0 is finally here, working as requested:

https://www.donation...ex.php?topic=51403.0

Enjoy!  :Thmbsup:
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

Thanks for a great program,
I have a few update ideas.

1. Ouput the data to a text file.
c:\WeatherToText.exe https://www.klart.se/se/södermanlands-län/väder-alberga/timmar/ yellow > Weather.txt

2. Get weather overview from the "14 day output" page.
https://www.klart.se.../v%C3%A4der-alberga/
Note that the page says "14 dagar" (dagar = days) but it gives a forcast well beyond, up to 24th december at this point.
(This doesnt need to be the same program if it easier to make a seperate program)

Im thinking something like this would give the forcast for 10 days, yellow output and 10 day output.
c:\WeatherToText.exe https://www.klart.se/se/södermanlands-län/väder-alberga/ yellow /D 10

Text.png[IDEA] Display the weather in the command line (Weather forcast to text)
Klart.png[IDEA] Display the weather in the command line (Weather forcast to text)
You can get the moon phase by clicking "Detaljvy" (marked with a big arrow in the picture)

Translations
Swedish -> English
  • Lägsta = Lowest
  • Sol      =Sun
  • Upp     = Up
  • Ned     = Down
  • Regn    = Rain
  • Månfas  = Moon phase
  • Tilltagande = Increasing
  • Avtagande = Decreasing
  • Fullmånde = Full moon
  • Detaljvy    = Detail view
  • Dagar     = Days
  • Idag       = Today
  • Måndag  = Monday
  • Tisdag    = Tuesday
  • Onsdag   = Wednesday
  • Torsdag  = Thursday
  • Fredag   = Friday
  • Lördag   = Saturday
  • Söndag  = Sunday
« Last Edit: December 11, 2021, 11:47 AM by user45454 »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member

Thanks for a great program,
I have a few update ideas.

I'm in! :Thmbsup: I have several half-baked ones about to release right now so please ping back after Christmas. I should have published several of the most impending releases for the month by then :)

Happy to serve you again,
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
« Last Edit: December 11, 2021, 06:54 PM by publicdomain »

user45454

  • Participant
  • Joined in 2010
  • *
  • Posts: 22
    • View Profile
    • Donate to Member
Hi,

I have some ideas for changes for the new  "14 day output" version.
I dont The Moon phase "månfas" is not very usefull, it can be removed and replaced with thunder probability, that is much more useful.

Thunder is called "Sannolikhet åska" and like the current version of Weather2Text only a percentage is needed, not the text part.
The page writes "Sannolikhet åska Ingen (0%)" (translated: probability thunder None (0%)"

If we get the possibility to do the Weather2Text ouput to a textfile Im thinking of scheduling the output to a webpage and break free from big weathers telementry data and their apps.  :D

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 736
  • Call me Vic!
    • View Profile
    • Donate to Member
Sure! I'm currently doing a coding spree :Thmbsup:

If we get the possibility to do the Weather2Text ouput to a textfile Im thinking of scheduling the output to a webpage and break free from big weathers telementry data and their apps. 

Yup.  Do you want it timestamped or "fixed"? (i.e. Weather2Text.txt all the time or formatted like: YYYY-MM-DD-HH-MM-SS.txt)

Cheers!
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