ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

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

(1/7) > >>

user45454:
What I want: To display the weather from www.klart.se in the command line.

From this page https://www.klart.se/se/s%C3%B6dermanlands-l%C3%A4n/v%C3%A4der-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.

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

publicdomain:
What I want: To display the weather from www.klart.se in the command line.

From this page https://www.klart.se/se/s%C3%B6dermanlands-l%C3%A4n/v%C3%A4der-alberga/timmar/
-user45454 (May 12, 2021, 06:39 PM)
--- End quote ---

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

https://github.com/publicdomain/weather-to-text

wraith808:
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 ---<#Get-Weather Created in response to a request on DonationCoder- https://www.donationcoder.com/forum/index.php?topic=51394 Retrieves weather from http://wttr.in/ and prints it to commandline Parameters:-City: [required] City to retrieve the weather for-IncludeTomorrow : Also include tomorrow's weather-IncludeNext2Days : Also include the weather for the next two days #> param (    [string]$City = $( Read-Host "Enter name of the City to get weather report" ),    [switch] $IncludeTomorrow,    [switch] $IncludeNext2Days    ) try {    $url = "http://wttr.in/$($City)"     $Weather = $(Invoke-WebRequest $url –UserAgent curl).content -split "`n"     if($Weather)    {        $Weather[0..16]        if(($IncludeTomorrow) -or ($IncludeNext2Days)){ $Weather[17..26] }        if($IncludeNext2Days){ $Weather[27..36] }    }}catch {    $_.exception.Message}

publicdomain:
So, this isn't exactly what you asked for, but it was an interesting problem, so I did it anyway :)
-wraith808 (May 13, 2021, 11:17 PM)
--- End quote ---

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



Note that I changed some tittles in the command line version.
-user45454 (May 12, 2021, 06:39 PM)
--- End quote ---

WeatherToText v0.1.0 is released: https://www.donationcoder.com/forum/index.php?topic=51403.0

Text substitution comes @ v0.1.1

Please check what's there suits you Cheers!

user45454:
So, this isn't exactly what you asked for, but it was an interesting problem, so I did it anyway :)
-wraith808 (May 13, 2021, 11:17 PM)
--- End quote ---

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



Note that I changed some tittles in the command line version.
-user45454 (May 12, 2021, 06:39 PM)
--- End quote ---

WeatherToText v0.1.0 is released: https://www.donationcoder.com/forum/index.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)
--- End quote ---

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

 :o

Navigation

[0] Message Index

[#] Next page

Go to full version