It is currently April 27th, 2024, 10:13 am

Yahoo Weather Fix

Get help with creating, editing & fixing problems with skins
Ambrotos88
Posts: 4
Joined: March 30th, 2023, 10:00 am

Yahoo Weather Fix

Post by Ambrotos88 »

Hello guys,

I know someone posted a fix for Yahoo Weather, but I have extracted better values. So, those who want to use Yahoo weather in their skins or old skins working on Yahoo weather can use this.

This expression will give you the below information.

Code: Select all

(?siU)<h1 class="Fz\(3rem\).*Wob\(ba\)">(.*)</h1>.*<h2 class="D\(b\).*Trsdu\(.3s\)">(.*)</h2>.*<div class="My\(2px\).*Fz\(1.12rem\)">(.*)</p>.*<svg class="arrowUp.*celsius_D\(n\)">(.*)</span>.*<svg class="arrowDown.*celsius_D\(n\)">(.*)</span>.*<div class="temperature-forecast.*celsius_D\(n\)">(.*)</span>.*<dl class="D\(tbc\) W\(60%\).*kilometers_D\(n\)">(.*)</dd>.*<div class="D\(f\) Py\(8px\).*<dd>(.*)</dd>
1 = Place
2 = Country
3 = Weather Condition
4 = Max Temp Fer
5 = Min Temp Fer
6 = Current Temp Fer
7 = Wind Speed mph (direction)
8 = Humidity %

Example:

1 => St. Louis
2 => United States
3 => Rain
4 => 71&deg;
5 => 43&deg;
6 => 59
7 => 9 mph South
8 => 74%


And below expression will give you day-wise weather information.

Code: Select all

(?siU)<tr class="Bdb\ Bds\(d\).*</button>(.*)</td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)</dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)</dd>.*<tr class="Bdb\ Bds\(d\).*</button>(.*)</td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)</dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)</dd>.*<tr class="Bdb\ Bds\(d\).*</button>(.*)</td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)</dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)</dd>.*<tr class="Bdb\ Bds\(d\).*</button>(.*)</td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)</dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)</dd>.*<tr class="Bdb\ Bds\(d\).*</button>(.*)</td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)</dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)</dd>.*<tr class="Bdb\ Bds\(d\).*</button>(.*)</td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)</dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)</dd>
Example:

1 => Friday
2 => Thunderstorms
3 => 71°
4 => 43°
5 => Saturday
6 => Sunny
7 => 55°
8 => 35°
9 => Sunday
10 => Sunny
11 => 66°
12 => 50°
13 => Monday
14 => "Mostly Cloudy"
15 => 70°
16 => 61°
17 => Tuesday
18 => Thunderstorms
19 => 80°
20 => 52°
21 => Wednesday
22 => Thunderstorms
23 => 63°
24 => 40°

I have yet to extract the temperature in celsius in this code; if you want it, I can help to fetch those values in celsius too. Plus, If the weather condition has two or more words, e.g. "Mostly Cloudy", "Partly Cloudy", etc., RegExp fetches those weather conditions in quotation marks. So far, I have not found any solution for that. If I find any solution, I will post it here.

Please answer if anyone knows how to fetch weather conditions with two or more words without quotation marks.

Thank you.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Yahoo Weather Fix

Post by eclectic-tech »

It is good to see someone take interest in keeping Yahoo active as an alternative to weathercom. Good work!

The sad disadvantage of using Yahoo as the source is the lack of frequent updates, they only update the data approximately once an hour.
I recently updated my Yahoo skin Yahoo2023 and will share my regular expressions I use to get current details and the 10-day forecast.

Here is a list of the captured values:

Code: Select all

Current Weather Detail Captures for Yahoo 2023
1 => 8:22 AM
2 => rain_day_night@2x
3 => Rain
4 => 46
5 => 8
6 => Friday
7 => Thunderstorms
8 => 49%
9 => 58°
10 => 15°
11 => 46°
12 => 8°
13 => Morning
14 => Afternoon
15 => Evening
16 => Night
17 => 86%
18 => 68%
19 => 40%
20 => 63%
21 => 5 mph SE
22 => 8 km/h SE
23 => 29.9 inches
24 => 1014.2 millibars
25 => rain_day_night@2x
26 => 43
27 => 7
28 => 49%
29 => 11.00 miles
30 => 17.70 km
31 => 0 (Low)
32 => Today - Rain with a high of 56 °F (13.3 °C) and a 86% chance of precipitation. Winds variable at 14 to 25 mph (22.5 to 40.2 kph).
33 => Tonight - Cloudy with a 69% chance of precipitation. Winds from S to SSW at 19 to 27 mph (30.6 to 43.5 kph). The overnight low will be 56 °F (13.3 °C).
34 => Waxing Gibbous
35 => 7:14 AM
36 => 7:55 PM
37 => Huron
38 => Erie
39 => Ohio
40 => United States
41 => 41.373958
42 => -82.561753

10 Day Forecast Captures for Yahoo 2023
1 => Friday
2 => thundershowers_day_night@2x
3 => 49%
4 => 58°
5 => 15°
6 => 46°
7 => 8°
8 => Saturday
9 => rain_day_night@2x
10 => 34%
11 => 54°
12 => 13°
13 => 31°
14 => 0°
15 => Sunday
16 => partly_cloudy_day@2x
17 => 0%
18 => 46°
19 => 8°
20 => 41°
21 => 5°
22 => Monday
23 => mostly_cloudy_day_night@2x
24 => 6%
25 => 61°
26 => 17°
27 => 47°
28 => 9°
29 => Tuesday
30 => rain_day_night@2x
31 => 34%
32 => 59°
33 => 15°
34 => 57°
35 => 14°
36 => Wednesday
37 => mostly_cloudy_day_night@2x
38 => 34%
39 => 74°
40 => 24°
41 => 46°
42 => 8°
43 => Thursday
44 => partly_cloudy_day@2x
45 => 0%
46 => 49°
47 => 10°
48 => 39°
49 => 4°
50 => Friday
51 => clear_day@2x
52 => 0%
53 => 51°
54 => 11°
55 => 47°
56 => 9°
57 => Saturday
58 => mostly_cloudy_day_night@2x
59 => 7%
60 => 55°
61 => 13°
62 => 47°
63 => 9°
64 => Sunday
65 => scattered_showers_day_night@2x
66 => 19%
67 => 57°
68 => 14°
69 => 44°
70 => 7°
The site address is: URL=https://www.yahoo.com/news/weather/

Here is the RegExp I use for the current weather details:

Code: Select all

RegExp=(?siU).*<time class=.*, (.*)</time>.*<div class="My\(2px\).*60x60\/(.*).png.*<p class=.*>(.*)</p>.*class="temperature-forecast .*> <span class=.*>(.*)</span><span class=.*>(.*)</span>.*<tr class=.*forecast-item.*</button>(.*)<.*alt=(.*)>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<div id=module-weather-precipitation.*scope=col>(.*)<.*scope=col>(.*)<.*scope=col>(.*)<.*scope=col>(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*<div id=module-weather-wind-pressure.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<div id=module-weather-details.*<img class=.*60x60\/(.*).png.*<dd class=.*">(.*)&.*</dd><dd class=.*>(.*)&.*</dd>.*<dd>(.*)</dd>.*<dd.*>(.*)</dd>.*<dd.*>(.*)</dd>.*<dd>(.*)</dd>.*<p class=.*>(.*)</p>.*<p class=.*>(.*)</p>.*<div id=module-weather-sun-moon.*<dd>(.*)</dd>.*<time class=.*>(.*)</time><time class=.*>(.*)</time>.*data-meta='.*"city":"(.*)".*"county":"(.*)".*"state":"(.*)".*"country":"(.*)".*"lat":(.*),.*"lon":(.*),
Here is the RegExp I use for thr 10-day forecast:

Code: Select all

RegExp=(?siU).*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>
I use Substitution to capture the actual condition icon image name (This also removes any " characters):

Code: Select all

[.CurrentConditions]
Measure=WebParser
URL=[.SuperParent]
StringIndex=3
Substitute='"':"","_":" "," day":""," night":"","@2x":""
I use RegExpSubstitute to separate the number of digits on values, for example:

Code: Select all

[.TodayFeelsLikeC]
Measure=WebParser
URL=[.SuperParent]
StringIndex=27
RegExpSubstitute=1
Substitute="^(\d{1,2}\..).*$":"\1"
or

Code: Select all

[.TodayWindSpeedC]
Measure=WebParser
URL=[.SuperParent]
StringIndex=22
RegExpSubstitute=1
Substitute="^(\d{0,3})\..*$":"\1"
In the Narrative I remove Yahoo's degree character (Â):

Code: Select all

[.TodayNightNarrative]
Measure=WebParser
URL=[.SuperParent]
StringIndex=32
Substitute="Â":""
Hopefully, you will find this information useful...
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Yahoo Weather Fix

Post by Yincognito »

Ambrotos88 wrote: March 31st, 2023, 8:45 amPlus, If the weather condition has two or more words, e.g. "Mostly Cloudy", "Partly Cloudy", etc., RegExp fetches those weather conditions in quotation marks. So far, I have not found any solution for that. If I find any solution, I will post it here.

Please answer if anyone knows how to fetch weather conditions with two or more words without quotation marks.
Your regexes are incorrect, because some slashes (/) have not been escaped by preceding them with backslashes (\). I also don't understand why you have the backslashes after the "Bdb parts, since the following space (if it's regular space, that is) doesn't need to be ecaped. So, the correct form would be (I let the latter as it was since it wasn't technically an error, feel free to adjust if desired):

Code: Select all

(?siU)<h1 class="Fz\(3rem\).*Wob\(ba\)">(.*)<\/h1>.*<h2 class="D\(b\).*Trsdu\(.3s\)">(.*)<\/h2>.*<div class="My\(2px\).*Fz\(1.12rem\)">(.*)<\/p>.*<svg class="arrowUp.*celsius_D\(n\)">(.*)<\/span>.*<svg class="arrowDown.*celsius_D\(n\)">(.*)<\/span>.*<div class="temperature-forecast.*celsius_D\(n\)">(.*)<\/span>.*<dl class="D\(tbc\) W\(60%\).*kilometers_D\(n\)">(.*)<\/dd>.*<div class="D\(f\) Py\(8px\).*<dd>(.*)<\/dd>
and

Code: Select all

(?siU)<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>
To get rid of quotation marks, you have two possibilities:
- if you do it after the capture, a simple regexp Substitute='(?:^"|"$)':"" in the measure where you extract the capture is enough
- if you do it before the capture, setting the part around your 14th capture from alt=(.*)> to alt="??(.*)"??> in the expression is enough
Choosing between them is a matter of preference. As far as I understand, the 14th capture is extracted with quotes because those quotes can either be present or missing from the source. The two question marks after each quote above handle that possibility, since:
- the 1st is a regex optional, matching either 0 or 1 times the preceding token (i.e. match quotes whether they exist or not)
- the 2nd is a lazy quantifier to "invert" the ungreedy behavior set by the ?U flag at the beginning of the expression to greedy in this case and match as many characters as possible (i.e. if quotes exist, take them 1 time instead of 0 time and keep them out of the adjacent capture)

As for eclectic-tech's reply, you can use his methods too (after all, he made a complete version of grabbing weather from Yahoo), although personally I would not rely on patterns like 2x, 60x60 and similar, see here and here. I didn't complete that approach since eclectic-tech one was already in the making / updated and I was quite busy with other stuff at that time. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Yahoo Weather Fix

Post by eclectic-tech »

Yincognito wrote: March 31st, 2023, 1:49 pm {..clip..}
As for eclectic-tech's reply, you can use his methods too (after all, he made a complete version of grabbing weather from Yahoo), although personally I would not rely on patterns like 2x, 60x60 and similar, see here and here. I didn't complete that approach since eclectic-tech one was already in the making / updated and I was quite busy with other stuff at that time. ;-)
Yahoo does not use simple numbers for their condition icons, so I borrowed Xenium's approach to capture the portions necessary to create the condition icon's image file name: e.g.; "cloudy_day_night@2x.png"

There may be simpler or more reliable ways to do this, but it is working for now. 8-)

BTW, I learn a lot from your Regular Expression suggestions, saves me from trying to decipher some of those expressions... Thanks! :great:
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Yahoo Weather Fix

Post by Yincognito »

eclectic-tech wrote: March 31st, 2023, 10:02 pmYahoo does not use simple numbers for their condition icons, so I borrowed Xenium's approach to capture the portions necessary to create the condition icon's image file name: e.g.; "cloudy_day_night@2x.png"
There may be simpler or more reliable ways to do this, but it is working for now. 8-)
Ah, I see now, I wasn't paying attention that you're using them to capture parts of the .png icon name - my bad. I meant that these "numbers" shouldn't be used as anchors in other places, i.e. unrelated to the .png names - if this happens, that is. Though now, that you explained it, maybe the instances I saw earlier in other places were also related to the icons' names and I rushed to conclusions too early... :???:

My point was that it's not "durable" for general matching in the page (except the image cases above, of course) to use "numbers" or parts like these, since they might change often depending on the resource set used by Yahoo, unlike parts that are much less likely to change, i.e. various HTML tag names, id or class names that can't be spelled or written otherwise (e.g. temperature-forecast and the like). Personally, I try to avoid repeating the work of setting up a regex in the future if I can, for efficiency purposes.
eclectic-tech wrote: March 31st, 2023, 10:02 pmBTW, I learn a lot from your Regular Expression suggestions, saves me from trying to decipher some of those expressions... Thanks! :great:
Nah, I'm not that much of a "guru" in regular expressions - I just like them because they seem simple to me (however difficult that might be to believe). That being said, you're absolutely right: building a regular expression is MUCH easier than deciphering one ... especially when its author is not the same or the expression is longer. It's not so much about identifying the character classes or what they mean, but rather the fact that it's visually difficult to identify where various parts begin and end in a longer string of somewhat similar characters (and without special coloring).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Ambrotos88
Posts: 4
Joined: March 30th, 2023, 10:00 am

Re: Yahoo Weather Fix

Post by Ambrotos88 »

Yincognito wrote: March 31st, 2023, 1:49 pm Your regexes are incorrect, because some slashes (/) have not been escaped by preceding them with backslashes (\). I also don't understand why you have the backslashes after the "Bdb parts, since the following space (if it's regular space, that is) doesn't need to be ecaped. So, the correct form would be (I let the latter as it was since it wasn't technically an error, feel free to adjust if desired):

Code: Select all

(?siU)<h1 class="Fz\(3rem\).*Wob\(ba\)">(.*)<\/h1>.*<h2 class="D\(b\).*Trsdu\(.3s\)">(.*)<\/h2>.*<div class="My\(2px\).*Fz\(1.12rem\)">(.*)<\/p>.*<svg class="arrowUp.*celsius_D\(n\)">(.*)<\/span>.*<svg class="arrowDown.*celsius_D\(n\)">(.*)<\/span>.*<div class="temperature-forecast.*celsius_D\(n\)">(.*)<\/span>.*<dl class="D\(tbc\) W\(60%\).*kilometers_D\(n\)">(.*)<\/dd>.*<div class="D\(f\) Py\(8px\).*<dd>(.*)<\/dd>
and

Code: Select all

(?siU)<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>.*<tr class="Bdb\ Bds\(d\).*<\/button>(.*)<\/td>.*<td class="Ta\(c\) W\(25%\)">.*alt=(.*)>.*<dd class="D\(b\).*W\(25px\)">(.*)<\/dd>.*<dd class="Pstart\(10px\).*W\(25px\)">(.*)<\/dd>
To get rid of quotation marks, you have two possibilities:
- if you do it after the capture, a simple regexp Substitute='(?:^"|"$)':"" in the measure where you extract the capture is enough
- if you do it before the capture, setting the part around your 14th capture from alt=(.*)> to alt="??(.*)"??> in the expression is enough
Choosing between them is a matter of preference. As far as I understand, the 14th capture is extracted with quotes because those quotes can either be present or missing from the source. The two question marks after each quote above handle that possibility, since:
- the 1st is a regex optional, matching either 0 or 1 times the preceding token (i.e. match quotes whether they exist or not)
- the 2nd is a lazy quantifier to "invert" the ungreedy behavior set by the ?U flag at the beginning of the expression to greedy in this case and match as many characters as possible (i.e. if quotes exist, take them 1 time instead of 0 time and keep them out of the adjacent capture)

As for eclectic-tech's reply, you can use his methods too (after all, he made a complete version of grabbing weather from Yahoo), although personally I would not rely on patterns like 2x, 60x60 and similar, see here and here. I didn't complete that approach since eclectic-tech one was already in the making / updated and I was quite busy with other stuff at that time. ;-)


Thank you so much for the suggestions, mate.
It will help me a lot.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Yahoo Weather Fix

Post by Yincognito »

Ambrotos88 wrote: April 2nd, 2023, 11:42 am Thank you so much for the suggestions, mate.
It will help me a lot.
You're welcome - glad to help. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Ambrotos88
Posts: 4
Joined: March 30th, 2023, 10:00 am

Re: Yahoo Weather Fix

Post by Ambrotos88 »

eclectic-tech wrote: March 31st, 2023, 12:55 pm It is good to see someone take interest in keeping Yahoo active as an alternative to weathercom. Good work!

The sad disadvantage of using Yahoo as the source is the lack of frequent updates, they only update the data approximately once an hour.
I recently updated my Yahoo skin Yahoo2023 and will share my regular expressions I use to get current details and the 10-day forecast.

Here is a list of the captured values:

Code: Select all

Current Weather Detail Captures for Yahoo 2023
1 => 8:22 AM
2 => rain_day_night@2x
3 => Rain
4 => 46
5 => 8
6 => Friday
7 => Thunderstorms
8 => 49%
9 => 58°
10 => 15°
11 => 46°
12 => 8°
13 => Morning
14 => Afternoon
15 => Evening
16 => Night
17 => 86%
18 => 68%
19 => 40%
20 => 63%
21 => 5 mph SE
22 => 8 km/h SE
23 => 29.9 inches
24 => 1014.2 millibars
25 => rain_day_night@2x
26 => 43
27 => 7
28 => 49%
29 => 11.00 miles
30 => 17.70 km
31 => 0 (Low)
32 => Today - Rain with a high of 56 °F (13.3 °C) and a 86% chance of precipitation. Winds variable at 14 to 25 mph (22.5 to 40.2 kph).
33 => Tonight - Cloudy with a 69% chance of precipitation. Winds from S to SSW at 19 to 27 mph (30.6 to 43.5 kph). The overnight low will be 56 °F (13.3 °C).
34 => Waxing Gibbous
35 => 7:14 AM
36 => 7:55 PM
37 => Huron
38 => Erie
39 => Ohio
40 => United States
41 => 41.373958
42 => -82.561753

10 Day Forecast Captures for Yahoo 2023
1 => Friday
2 => thundershowers_day_night@2x
3 => 49%
4 => 58°
5 => 15°
6 => 46°
7 => 8°
8 => Saturday
9 => rain_day_night@2x
10 => 34%
11 => 54°
12 => 13°
13 => 31°
14 => 0°
15 => Sunday
16 => partly_cloudy_day@2x
17 => 0%
18 => 46°
19 => 8°
20 => 41°
21 => 5°
22 => Monday
23 => mostly_cloudy_day_night@2x
24 => 6%
25 => 61°
26 => 17°
27 => 47°
28 => 9°
29 => Tuesday
30 => rain_day_night@2x
31 => 34%
32 => 59°
33 => 15°
34 => 57°
35 => 14°
36 => Wednesday
37 => mostly_cloudy_day_night@2x
38 => 34%
39 => 74°
40 => 24°
41 => 46°
42 => 8°
43 => Thursday
44 => partly_cloudy_day@2x
45 => 0%
46 => 49°
47 => 10°
48 => 39°
49 => 4°
50 => Friday
51 => clear_day@2x
52 => 0%
53 => 51°
54 => 11°
55 => 47°
56 => 9°
57 => Saturday
58 => mostly_cloudy_day_night@2x
59 => 7%
60 => 55°
61 => 13°
62 => 47°
63 => 9°
64 => Sunday
65 => scattered_showers_day_night@2x
66 => 19%
67 => 57°
68 => 14°
69 => 44°
70 => 7°
The site address is: URL=https://www.yahoo.com/news/weather/

Here is the RegExp I use for the current weather details:

Code: Select all

RegExp=(?siU).*<time class=.*, (.*)</time>.*<div class="My\(2px\).*60x60\/(.*).png.*<p class=.*>(.*)</p>.*class="temperature-forecast .*> <span class=.*>(.*)</span><span class=.*>(.*)</span>.*<tr class=.*forecast-item.*</button>(.*)<.*alt=(.*)>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<div id=module-weather-precipitation.*scope=col>(.*)<.*scope=col>(.*)<.*scope=col>(.*)<.*scope=col>(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*<div id=module-weather-wind-pressure.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<div id=module-weather-details.*<img class=.*60x60\/(.*).png.*<dd class=.*">(.*)&.*</dd><dd class=.*>(.*)&.*</dd>.*<dd>(.*)</dd>.*<dd.*>(.*)</dd>.*<dd.*>(.*)</dd>.*<dd>(.*)</dd>.*<p class=.*>(.*)</p>.*<p class=.*>(.*)</p>.*<div id=module-weather-sun-moon.*<dd>(.*)</dd>.*<time class=.*>(.*)</time><time class=.*>(.*)</time>.*data-meta='.*"city":"(.*)".*"county":"(.*)".*"state":"(.*)".*"country":"(.*)".*"lat":(.*),.*"lon":(.*),
Here is the RegExp I use for thr 10-day forecast:

Code: Select all

RegExp=(?siU).*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>
I use Substitution to capture the actual condition icon image name (This also removes any " characters):

Code: Select all

[.CurrentConditions]
Measure=WebParser
URL=[.SuperParent]
StringIndex=3
Substitute='"':"","_":" "," day":""," night":"","@2x":""
I use RegExpSubstitute to separate the number of digits on values, for example:

Code: Select all

[.TodayFeelsLikeC]
Measure=WebParser
URL=[.SuperParent]
StringIndex=27
RegExpSubstitute=1
Substitute="^(\d{1,2}\..).*$":"\1"
or

Code: Select all

[.TodayWindSpeedC]
Measure=WebParser
URL=[.SuperParent]
StringIndex=22
RegExpSubstitute=1
Substitute="^(\d{0,3})\..*$":"\1"
In the Narrative I remove Yahoo's degree character (Â):

Code: Select all

[.TodayNightNarrative]
Measure=WebParser
URL=[.SuperParent]
StringIndex=32
Substitute="Â":""
Hopefully, you will find this information useful...

Thank you so much.
It is indeed helpful. I really appreciate.
Ambrotos88
Posts: 4
Joined: March 30th, 2023, 10:00 am

Re: Yahoo Weather Fix

Post by Ambrotos88 »

eclectic-tech wrote: March 31st, 2023, 12:55 pm It is good to see someone take interest in keeping Yahoo active as an alternative to weathercom. Good work!

The sad disadvantage of using Yahoo as the source is the lack of frequent updates, they only update the data approximately once an hour.
I recently updated my Yahoo skin Yahoo2023 and will share my regular expressions I use to get current details and the 10-day forecast.

Here is a list of the captured values:

Code: Select all

Current Weather Detail Captures for Yahoo 2023
1 => 8:22 AM
2 => rain_day_night@2x
3 => Rain
4 => 46
5 => 8
6 => Friday
7 => Thunderstorms
8 => 49%
9 => 58°
10 => 15°
11 => 46°
12 => 8°
13 => Morning
14 => Afternoon
15 => Evening
16 => Night
17 => 86%
18 => 68%
19 => 40%
20 => 63%
21 => 5 mph SE
22 => 8 km/h SE
23 => 29.9 inches
24 => 1014.2 millibars
25 => rain_day_night@2x
26 => 43
27 => 7
28 => 49%
29 => 11.00 miles
30 => 17.70 km
31 => 0 (Low)
32 => Today - Rain with a high of 56 °F (13.3 °C) and a 86% chance of precipitation. Winds variable at 14 to 25 mph (22.5 to 40.2 kph).
33 => Tonight - Cloudy with a 69% chance of precipitation. Winds from S to SSW at 19 to 27 mph (30.6 to 43.5 kph). The overnight low will be 56 °F (13.3 °C).
34 => Waxing Gibbous
35 => 7:14 AM
36 => 7:55 PM
37 => Huron
38 => Erie
39 => Ohio
40 => United States
41 => 41.373958
42 => -82.561753

10 Day Forecast Captures for Yahoo 2023
1 => Friday
2 => thundershowers_day_night@2x
3 => 49%
4 => 58°
5 => 15°
6 => 46°
7 => 8°
8 => Saturday
9 => rain_day_night@2x
10 => 34%
11 => 54°
12 => 13°
13 => 31°
14 => 0°
15 => Sunday
16 => partly_cloudy_day@2x
17 => 0%
18 => 46°
19 => 8°
20 => 41°
21 => 5°
22 => Monday
23 => mostly_cloudy_day_night@2x
24 => 6%
25 => 61°
26 => 17°
27 => 47°
28 => 9°
29 => Tuesday
30 => rain_day_night@2x
31 => 34%
32 => 59°
33 => 15°
34 => 57°
35 => 14°
36 => Wednesday
37 => mostly_cloudy_day_night@2x
38 => 34%
39 => 74°
40 => 24°
41 => 46°
42 => 8°
43 => Thursday
44 => partly_cloudy_day@2x
45 => 0%
46 => 49°
47 => 10°
48 => 39°
49 => 4°
50 => Friday
51 => clear_day@2x
52 => 0%
53 => 51°
54 => 11°
55 => 47°
56 => 9°
57 => Saturday
58 => mostly_cloudy_day_night@2x
59 => 7%
60 => 55°
61 => 13°
62 => 47°
63 => 9°
64 => Sunday
65 => scattered_showers_day_night@2x
66 => 19%
67 => 57°
68 => 14°
69 => 44°
70 => 7°
The site address is: URL=https://www.yahoo.com/news/weather/

Here is the RegExp I use for the current weather details:

Code: Select all

RegExp=(?siU).*<time class=.*, (.*)</time>.*<div class="My\(2px\).*60x60\/(.*).png.*<p class=.*>(.*)</p>.*class="temperature-forecast .*> <span class=.*>(.*)</span><span class=.*>(.*)</span>.*<tr class=.*forecast-item.*</button>(.*)<.*alt=(.*)>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<div id=module-weather-precipitation.*scope=col>(.*)<.*scope=col>(.*)<.*scope=col>(.*)<.*scope=col>(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*Fz\(1rem\)">(.*)<.*<div id=module-weather-wind-pressure.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<dd class=.*>(.*)<.*<div id=module-weather-details.*<img class=.*60x60\/(.*).png.*<dd class=.*">(.*)&.*</dd><dd class=.*>(.*)&.*</dd>.*<dd>(.*)</dd>.*<dd.*>(.*)</dd>.*<dd.*>(.*)</dd>.*<dd>(.*)</dd>.*<p class=.*>(.*)</p>.*<p class=.*>(.*)</p>.*<div id=module-weather-sun-moon.*<dd>(.*)</dd>.*<time class=.*>(.*)</time><time class=.*>(.*)</time>.*data-meta='.*"city":"(.*)".*"county":"(.*)".*"state":"(.*)".*"country":"(.*)".*"lat":(.*),.*"lon":(.*),
Here is the RegExp I use for thr 10-day forecast:

Code: Select all

RegExp=(?siU).*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<tr class=.*forecast-item.*</button>(.*)<.*<img class=.*60x60\/(.*).png.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>.*<dd class=".*">(.*)</dd>
I use Substitution to capture the actual condition icon image name (This also removes any " characters):

Code: Select all

[.CurrentConditions]
Measure=WebParser
URL=[.SuperParent]
StringIndex=3
Substitute='"':"","_":" "," day":""," night":"","@2x":""
I use RegExpSubstitute to separate the number of digits on values, for example:

Code: Select all

[.TodayFeelsLikeC]
Measure=WebParser
URL=[.SuperParent]
StringIndex=27
RegExpSubstitute=1
Substitute="^(\d{1,2}\..).*$":"\1"
or

Code: Select all

[.TodayWindSpeedC]
Measure=WebParser
URL=[.SuperParent]
StringIndex=22
RegExpSubstitute=1
Substitute="^(\d{0,3})\..*$":"\1"
In the Narrative I remove Yahoo's degree character (Â):

Code: Select all

[.TodayNightNarrative]
Measure=WebParser
URL=[.SuperParent]
StringIndex=32
Substitute="Â":""
Hopefully, you will find this information useful...

I saw that weather units had not been extracted; I could do it with the below code.

Code: Select all

(?siU)<span class="temperature-unit D\(f\).*:1;>(.*)</button>.*<button id=celsius.*:1;>(.*)</button>
I hope it helps.
KRou
Posts: 24
Joined: January 26th, 2023, 5:05 pm

Re: Yahoo Weather Fix

Post by KRou »

Thanks for the RegExp it was very helpful to me :D :thumbup: