8

Current Location Weather (Yahoo)

Posted in Weather by ejleon 1509 days ago

Here is my attempt to create current location weather for GeekTool.

I edited code from this website and give credit to the person who created it. Thank you!

I will add Weather Image soon. I will try to add a 5 day forecast geeklet file too later.

Image Name

The code I wrote for this. Second Geeklet. Current Weather 2.

W=curl "https://weather.yahoo.com" S=(echo "$W" | grep "region" | sed 's/<[^>]*>//g' | head -2 | tail -1 | sed 's/region://g' | sed -e "s/'//g") C=(echo "$W" | grep '"name"' | sed 's/<[^>]*>//g' | head -1 | tail -1 | sed 's/region://g' | sed -e "s/'//g") F=(echo "$W" | grep 'div class="cond' | sed 's/<[^>]*>//g' | head -2 | tail -1 | sed 's/region://g' | sed -e "s/'//g") T=(echo "$W" | grep '"num"' | sed 's/<[^>]*>//g' | head -1 | tail -1 | sed 's/region://g' | sed -e "s/'//g" | sed -e "s/°/°F/g") H=(echo "$W" | grep '"hi f w-up-arrow"'| sed 's/<[^>]*>//g' | head -1 | tail -1 | sed 's/region://g' | sed -e "s/'//g" | sed -e "s/°/°F/g") L=(echo "$W" | grep '"lo f w-down-arrow"'| sed 's/<[^>]*>//g' | head -1 | tail -1 | sed 's/region://g' | sed -e "s/'//g" | sed -e "s/°/°F/g") D=(curl "https://weather.yahoo.com" | grep "Humidity" | awk '{print $86}' | sed 's/<[^>]*>//g' | sed 's/class=//g' | sed 's/"//g' | sed 's/value//g' | sed 's/n//g' | sed 's/>//g' | sed 's/\\\//g')

echo $C,$S echo $T " " $F " " echo "↑"$H "-" "↓"$L echo "$D Humidity"

Comments

User Avatar
JayProspero 1505 days ago
This is great, anyway to change it to centigrade?
User Avatar
ejleon 1503 days ago
Jay thanks.

https://weather.yahoo.com

To change to Centigrade, go to the site above and press the little F by the Current Temperature.

Then edit the shell code to have C instead of F.
User Avatar
TheInfection43 1400 days ago
Hi ejleon,

What sort of edits do I have to make to the shell code? Is it just replacing all of the %F with %C?
User Avatar
TheInfection43 1401 days ago
Hi ejleon,

What sort of edits do I have to make to the shell code? Is it just replacing all of the %F with %C?
User Avatar
ejleon 1390 days ago
I updated for Celsius
User Avatar
hayduke 1395 days ago
I have a shell script that uses the Yahoo feed and works for my current location.

I've been trying to get the same script working for a location outside of the US. I've modified it for the weather code for the city i want, but when I do, the shell comes up blank.

any ideas?
User Avatar
ejleon 1390 days ago
You modified which geeklet?

What city?

Can you send code so I can see?
User Avatar
SaMuTa 1158 days ago
it doesn't work any help ???
User Avatar
hayduke 1157 days ago
Still looking for a working Geek Tool script for my local area,

I don't use glets, I just want a code string that I can cut and paste and I can modify the args for my local area.

So far I i've tried Yahoo, Wunderground, Accuweather and Weather.com

I don't need any graphics or forecasts, just a text display of the current conditions.

Anyone have a working script?

I'm running GeekTool 3.2 on OS X 10.11.6

Log in to comment or register here.