It is currently February 29th, 2020, 4:12 am

weather.com - Parsing the HTML

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
jsmorley
Developer
Posts: 20297
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some Help With Parsing weather.com

Post by jsmorley »

Added UV Index values to WeatherComRegExp.inc and to WeatherComCurrent.inc

Get the new .rmskin in the first post of this thread.

If you are already using the templates for your skins, this should have no impact. Simply replace the above two file in your @Resources folder, and your existing skins should work without any change.

I do recommend staying current with the .inc files though. If you let what you use drift out of sync with the "standard", it will be that much harder to harmonize things later.
User avatar
SilverAzide
Posts: 700
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Some Help With Parsing weather.com

Post by SilverAzide »

jsmorley wrote:
January 27th, 2020, 3:34 pm
Added UV Index values to WeatherComRegExp.inc and to WeatherComCurrent.inc
Would you or anyone be interested in a minor enhancement to allow getting "severe weather alerts"? I have modified the priority alert regexp to grab the alert URL in addition to the existing data, and created the corresponding include file for all the measures. I have not attempted to address the full set of alerts (via the main "ALERT" regexp) at this time.

Thanks to Xenium's clever look-aheads, the measures return nothing if there is no alert at all. The "priority alert" appears to fetch the first alert for a location (the first one shown in the list on the webpage, which seems to be ordered highest priority to lowest, and then by expiration timestamp).
Last edited by SilverAzide on January 27th, 2020, 4:43 pm, edited 1 time in total.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20297
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some Help With Parsing weather.com

Post by jsmorley »

If you want to see how this is brought together, and what you might use to create a weather skin that doesn't make use of the template .inc files I provide, (not sure I really recommend this, but to each his own) the following may be of some interest:

Code: Select all

https://weather.com/en-US/weather/today/l/USVA0944
Current=(?siU)(?(?=.*</div></span><p class="today_nowcard-).*timestamp"><span>(.*)<!----> </span><span>(.*)</span>).*(?(?=.*<div class="today_nowcard-section today_nowcard-condition"><div class="condition-icon wx-weather-icon vector).*"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today_nowcard-temp").*><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-phrase).*">(.*)</div>)(?(?=.*<div class="today_nowcard-feels).*"><span class="btn-text">(.*)<!----> </span><span class="deg-feels" className="deg-feels">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-hilo").*><span class="btn-text">.*<!----> </span><span class="deg-hilo-nowcard"><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<span class="btn-text">.*<!---->).* </span><span class="deg-hilo-nowcard"><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-sidecar component panel"><table><caption>(.*)</caption><tbody>).*<tr><th>(.*)</th><td><span class="">(.*)</span></td></tr><tr><th>(.*)</th><td><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span></span></span></td></tr><tr><th>(.*)</th><td><span class="">(.*)<sup>(.*)</sup></span></td></tr><tr><th>(.*)</th><td><span class="">(.*)<!---->.*</span></td></tr><tr><th>(.*)</th><td><span class="">(.*)</span></td>)
  1 => Text prefix for time of observation (example: as of)
  2 => Time of observation (example : 5:56 pm EST)
  3 => Current Conditions Icon number (example : 11)
  4 => Current Conditions Temperature (example : 34)
  5 => Current Conditions Temperature Symbol (example : °)
  6 => Current Conditions Text (example : Rain Shower)
  7 => Current Feels Like Text (example : Feels Like)
  8 => Current Feels Like Temperature (example : 28)
  9 => Current Feels Like Temperature Symbol (example : °)
10 => Today Low Temperature (example : 37)
11 => Today Low Temperature Symbol (example : °)
          Note that after a point in the afternoon, there will be no Low Temperature returned.
          At that point the value for High Temperature will be the low for Tonight until midnight.
12 => Today High Temperature (example : 51)
13 => Today High Temperature Symbol (example : °)
14 => UV Index Text (example : UV Index)
15 => UV Index (example : 2 of 10)
16 => Current Conditions Title (example : Right Now)
17 => Wind Text (example : Wind)
18 => Wind direction and speed (example : WSW 8 mph)
19 => Humidity Text (example : Humidity)
20 => Humidity Percentage (example : 89)
21 => Humidity Percentage Symbol (example : %)
22 => Dew Point Text (example : Dew Point)
23 => Dew Point (example : 30)
24 => Dew Point Symbol (example : °) 
25 => Barometric Pressure Text (example : Pressure)
26 => Barometric Pressure Value (example : 30.06 in)
27 => Visibility Text (example : Visibility)
28 => Visibility Distance (example : 5.0 mi)

https://weather.com/en-US/weather/today/l/USVA0944
36HourCards=(?siU)(?(?=.*<div class="today-daypart daypart-0).*  selected" id="daypart-0" data-track-string="today-looking-ahead_lookingAhead0hours" className="today-daypart daypart-0  selected"><div class="today-daypart-content" className="today-daypart-content"><div class="today-daypart-top"><span class="today-daypart-title" id="dp0-daypartName">(.*)</span>)(?(?=.*<span class="today-daypart-wxphrase").* id="dp0-phrase">(.*)</span></div>)(?(?=.*<div class="condition-icon wx-weather-icon").* aria-hidden="true" id="la-part0-icon"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today-daypart-hilo" id="dp0-).*highLow">(.*)</div>)(?(?=.*<div class="today-daypart-temp").*><span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*<div class="today-daypart-precip").*><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class="precip-val" className="precip-val"><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*<div class="today-daypart daypart-1").* id="daypart-1" data-track-string="today-looking-ahead_lookingAhead12hours" className="today-daypart daypart-1"><div class="today-daypart-content" className="today-daypart-content"><div class="today-daypart-top"><span class="today-daypart-title" id="dp1-daypartName">(.*)</span>)(?(?=.*<span class="today-daypart-wxphrase").* id="dp1-phrase">(.*)</span></div>)(?(?=.*<div class="condition-icon wx-weather-icon").* aria-hidden="true" id="la-part1-icon"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today-daypart-hilo" id="dp1-).*highLow">(.*)</div>)(?(?=.*<div class="today-daypart-temp").*><span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*<div class="today-daypart-precip").*><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class="precip-val" className="precip-val"><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*<div class="today-daypart daypart-2").* id="daypart-2" data-track-string="today-looking-ahead_lookingAhead24hours" className="today-daypart daypart-2"><div class="today-daypart-content" className="today-daypart-content"><div class="today-daypart-top"><span class="today-daypart-title" id="dp2-daypartName">(.*)</span>)(?(?=.*<span class="today-daypart-wxphrase").* id="dp2-phrase">(.*)</span></div>)(?(?=.*<div class="condition-icon wx-weather-icon").* aria-hidden="true" id="la-part2-icon"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today-daypart-hilo" id="dp2-).*highLow">(.*)</div>)(?(?=.*<div class="today-daypart-temp").*><span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*<div class="today-daypart-precip").*><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class="precip-val" className="precip-val"><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*<div class="today-daypart daypart-3").* id="daypart-3" data-track-string="today-looking-ahead_lookingAhead36hours" className="today-daypart daypart-3"><div class="today-daypart-content" className="today-daypart-content"><div class="today-daypart-top"><span class="today-daypart-title" id="dp3-daypartName">(.*)</span>)(?(?=.*<span class="today-daypart-wxphrase").* id="dp3-phrase">(.*)</span></div>)(?(?=.*<div class="condition-icon wx-weather-icon").* aria-hidden="true" id="la-part3-icon"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today-daypart-hilo" id="dp3-).*highLow">(.*)</div>)(?(?=.*<div class="today-daypart-temp").*><span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*<div class="today-daypart-precip").*><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class="precip-val" className="precip-val"><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*<div class="today-daypart daypart-4").* id="daypart-4" data-track-string="today-looking-ahead_lookingAhead48hours" className="today-daypart daypart-4"><div class="today-daypart-content" className="today-daypart-content"><div class="today-daypart-top"><span class="today-daypart-title" id="dp4-daypartName">(.*)</span>)(?(?=.*<span class="today-daypart-wxphrase").* id="dp4-phrase">(.*)</span></div>)(?(?=.*<div class="condition-icon wx-weather-icon").* aria-hidden="true" id="la-part4-icon"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today-daypart-hilo" id="dp4-).*highLow">(.*)</div>)(?(?=.*<div class="today-daypart-temp").*><span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*<div class="today-daypart-precip").*><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class="precip-val" className="precip-val"><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>)
 1 => Today
 2 => Sunny
 3 => 32
 4 => High
 5 => 40
 6 => °
 7 => 0
 8 => %
 9 => Tonight
10 => Mostly Cloudy
11 => 27
12 => Low
13 => 24
14 => °
15 => 0
16 => %
17 => Sat
18 => Rain/Snow
19 => 5
20 => High
21 => 38
22 => °
23 => 100
24 => %
25 => Sat Night
26 => Showers Early
27 => 45
28 => Low
29 => 37
30 => °
31 => 60
32 => %
33 => Sun
34 => Mostly Sunny
35 => 34
36 => High
37 => 41
38 => °
39 => 0
40 => %

https://weather.com/en-US/weather/tenday/l/USVA0944
Forecast=(?siU)(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>).*(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*(?(?=.*</td><td class="twc-sticky-col" headers="day" .* className="twc-sticky-col").*><div><div><span class="date-time">(.*)</span>)(?(?=.*<icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon).* icon-svg icon-svg-.* .* icon-.*">.*</icon>)(?(?=.*<div class="twc-table-shadow sticky" className="twc-table-shadow sticky").*></div></div><span class="day-detail clearfix">(.*)</span></div>)(?(?=.*</td><td class="description" .* className="description").*><span>(.*)</span>)(?(?=.*</td><td class="temp" .* className="temp").*><div><span class="">(.*)<sup>(.*)</sup></span>.*<span class="">(.*)<sup>(.*)</sup></span></div>)(?(?=.*</td><td class="precip" .* className="precip").*><div><span class="icon icon-font iconset-weather-data icon-drop-1" className="icon icon-font iconset-weather-data icon-drop-1"></span><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span>).*
 1 => Today
 2 => 30
 3 => JAN 27
 4 => Partly Cloudy
 5 => 0
 6 => %
 7 => Tue
 8 => 34
 9 => JAN 28
10 => Mostly Sunny
11 => 48
12 => °
13 => 29
14 => °
15 => 0
16 => %
17 => Wed
18 => 34
19 => JAN 29
20 => Mostly Sunny
21 => 44
22 => °
23 => 26
24 => °
25 => 0
26 => %
27 => Thu
28 => 30
29 => JAN 30
30 => Partly Cloudy
31 => 42
32 => °
33 => 27
34 => °
35 => 0
36 => %
37 => Fri
38 => 30
39 => JAN 31
40 => Partly Cloudy
41 => 47
42 => °
43 => 32
44 => °
45 => 10
46 => %
47 => Sat
48 => 39
49 => FEB 1
50 => PM Showers
51 => 48
52 => °
53 => 35
54 => °
55 => 30
56 => %
57 => Sun
58 => 39
59 => FEB 2
60 => AM Showers
61 => 46
62 => °
63 => 33
64 => °
65 => 40
66 => %
67 => Mon
68 => 34
69 => FEB 3
70 => Mostly Sunny
71 => 53
72 => °
73 => 38
74 => °
75 => 0
76 => %
77 => Tue
78 => 30
79 => FEB 4
80 => Partly Cloudy
81 => 56
82 => °
83 => 42
84 => °
85 => 20
86 => %
87 => Wed
88 => 11
89 => FEB 5
90 => Showers
91 => 47
92 => °
93 => 32
94 => °
95 => 40
96 => %

https://weather.com/en-US/weather/today/l/USVA0944
SunRiseSet=(?siU)(?(?=.*<span class="wx-detail-label show-sm">.*</span).*<span class="wx-dsxdate" id="dp0-details-(.*)">(.*)</span>.*<span class="wx-dsxdate" id="dp0-details-(.*)">(.*)</span>)
1 => sunrise
2 => 7:24 am
3 => sunset
4 => 5:12 pm

https://weather.com/en-US/weather/tenday/l/USVA0944
DetailsForecast=(?siU)(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>).*(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>).*(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>).*(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>).*(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>).*(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>).*(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>).*(?(?=.*<td class="twc-sticky-col" headers="day" title="(.*)").* .* className="twc-sticky-col"><div>)
1 => Sunny. High near 40F. Winds N at 10 to 15 mph.
2 => Scattered snow showers in the morning will give way to a mixture of rain and snow for the afternoon hours. Some mixed winter precipitation possible. High 38F. Winds S at 10 to 15 mph. Chance of precip 100%. Snow accumulations less than one inch.
3 => Mostly sunny skies. High 41F. Winds NW at 10 to 20 mph.
4 => Sunny. High 36F. Winds NNW at 10 to 15 mph.
5 => A mainly sunny sky. High 38F. Winds NNW at 5 to 10 mph.
6 => Sunny. High 41F. Winds light and variable.
7 => Sunshine and clouds mixed. High 46F. Winds light and variable.
8 => Partly cloudy. High 51F. Winds light and variable.

https://weather.com/en-US/weather/tenday/l/USVA0944
Details36Hours=(?siU)(?(?=.*{"dayPartName":"(.*)","precipPct":.*,"precipAmt":.*).*,"narrative":"(.*)").*(?(?=.*{"dayPartName":"(.*)","precipPct":.*,"precipAmt":.*).*,"narrative":"(.*)").*(?(?=.*{"dayPartName":"(.*)","precipPct":.*,"precipAmt":.*).*,"narrative":"(.*)").*(?(?=.*{"dayPartName":"(.*)","precipPct":.*,"precipAmt":.*).*,"narrative":"(.*)").*(?(?=.*{"dayPartName":"(.*)","precipPct":.*,"precipAmt":.*).*,"narrative":"(.*)").*
 1 => Today
 2 => Sunny. High near 40F. Winds N at 10 to 15 mph.
 3 => Tonight
 4 => Partly cloudy skies this evening will become overcast overnight. Some mixed winter precipitation possible. Low 24F. Winds light and variable.
 5 => Tomorrow
 6 => Scattered snow showers in the morning will give way to a mixture of rain and snow for the afternoon hours. Some mixed winter precipitation possible. High 38F. Winds S at 10 to 15 mph. Chance of precip 100%. Snow accumulations less than one inch.
 7 => Tomorrow night
 8 => Showers in the evening, then partly cloudy overnight. Low 37F. Winds SW at 10 to 20 mph. Chance of rain 60%.
 9 => Sunday
10 => Mostly sunny skies. High 41F. Winds NW at 10 to 20 mph.

https://weather.com/en-US/weather/today/l/USVA0944
PressureArrow=(?siU)<div class="today_nowcard-sidecar component panel"><table><caption>.*</caption><tbody>.*(?(?=.*<th>.*</th><td><span class="">.*<!----> <span class="icon icon-font iconset-arrows).* icon-arrow-.*-line" className="icon icon-font iconset-arrows icon-(.*)-line"></span>)
1 => arrow-down

https://weather.com/en-US/weather/today/l/USVA0944
TempUnit=<span class="icon icon-font iconset-ui icon-globe" className="icon icon-font iconset-ui icon-globe"></span><span>.*</span><span class="styles__borderLeft__2zhrE">°(\w)</span>
1 => Temperature Unit of Measure (example: F)

https://weather.com/en-US/weather/today/l/USVA0944
LocationName=(?siU)(?(?=.*<h1 class="h4 today_nowcard-location").* className="h4 today_nowcard-location">(.*)<span class=".*" className=".*"></span></h1>)
1 => Weather Location (example : Fort Hunt, VA)

https://weather.com/en-US/weather/today/l/USVA0944
UVText=(?siU)(?(?=.*</script><script charSet="UTF-8">window.i18n=).*"Wind":".*",.*,"UV Index":"(.*)")
1 = UV Index Text (example : UV Index)

https://weather.com/en-US/weather/today/l/USVA0944
UVValues=(?siU)"vt1observation":(?(?=.*{"altimeter":.*,.*).*"uvIndex":(.*),"uvDescription":"(.*)",.*})
1 => UV Index Number Value (example : 2)
2 => UV Index Text Value (example : Low)
User avatar
jsmorley
Developer
Posts: 20297
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some Help With Parsing weather.com

Post by jsmorley »

SilverAzide wrote:
January 27th, 2020, 4:40 pm
Would you or anyone be interested in a minor enhancement to allow getting "severe weather alerts"? I have modified the priority alert regexp to grab the alert URL in addition to the existing data, and created the corresponding include file for all the measures. I have not attempted to address the full set of alerts (via the main "ALERT" regexp) at this time.

Thanks to Xenium's clever look-aheads, the measures return nothing if there is no alert at all. The "priority alert" appears to fetch the first alert for a location (the first one shown in the list on the webpage, which seems to be ordered highest priority to lowest).
Sure, attach a file I can take a look at?
xenium
Posts: 474
Joined: January 4th, 2018, 9:52 pm

Re: ⭐ Some Help With Parsing weather.com

Post by xenium »

jsmorley wrote:
January 27th, 2020, 3:34 pm
Added UV Index values to WeatherComRegExp.inc and to WeatherComCurrent.inc

Get the new .rmskin in the first post of this thread.

If you are already using the templates for your skins, this should have no impact. Simply replace the above two file in your @Resources folder, and your existing skins should work without any change.

I do recommend staying current with the .inc files though. If you let what you use drift out of sync with the "standard", it will be that much harder to harmonize things later.
I noticed a display error in my skin after adding the UV index.
Enter a location where today's High Temp is no longer available (in Europe), and see if the UV and Low Temp indexes are displayed.
This is because when High Temp is no longer available, in the HTML code the High Temp section disappears.

I found another solution to display the UV Index.
See my skin.
User avatar
jsmorley
Developer
Posts: 20297
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some Help With Parsing weather.com

Post by jsmorley »

xenium wrote:
January 27th, 2020, 5:52 pm
I noticed a display error in my skin after adding the UV index.
Enter a location where today's High Temp is no longer available (in Europe), and see if the UV and Low Temp indexes are displayed.
This is because when High Temp is no longer available, in the HTML code the High Temp section disappears.

I found another solution to display the UV Index.
See my skin.
Yeah, it's an issue when it is "Tonight".


1.png


I'll take a look at how you approached it.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 20297
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some Help With Parsing weather.com

Post by jsmorley »

Yeah, that seems to fix it.

I actually think that might be a slightly better source, as what is displayed under the "36 hour cards" seems to be more "today", and what you changed to seems to be more "right now".


2.png


Updated the template files and all my skins.
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Posts: 700
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Some Help With Parsing weather.com

Post by SilverAzide »

jsmorley wrote:
January 27th, 2020, 4:43 pm
Sure, attach a file I can take a look at?
Attached is an include file for "priority alerts" as well as the adjusted regexp. Please feel free to alter in any way you see fit to conform to your style and preferences. I was unsure about the filename and group identifier, as it could clash with a future include of the complete set of alerts.

One annoyance with the weather data is that the "severityCode" style of identifying the type of alert that you are using in your Weather.com skin does not seem to have a 1:1 correspondence to the codes being captured here. The codes in xenium's regexp match the color of the icon they use in the UI, but these are somewhat inconsistent with the type of alert. For example, a "moderate" alert (severityCode 3) could show up as a 2 or 3 in the UI. The "severityCode" also references all sorts of annoying stuff like marine alerts ("Small Craft Advisory", etc.). This data does not seem to ever appear in the data xenium is capturing (fortunately); it also never appeared in wxdata either, IIRC.

Another annoyance is that TWC usually orders the codes to most-to-least significant, but not always. I can't figure out their logic (if any). The "priority alert" regexp does capture the first alert that appears at the top of the pulldown list of alerts, but unfortunately this first one isn't always the most important. Secondly, the wording TWC uses for the severity is somewhat inconsistent (in the US, anyway). Specifically, I see "Special Weather Statements" with severities of 4, 3, or 2. Watches, warnings, advisories seem more consistent. The European alerts seem to have more clear and verbose titles than what the US NWS uses.
Image1.png
You do not have the required permissions to view the files attached to this post.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20297
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some Help With Parsing weather.com

Post by jsmorley »

I think I'm going to stick with what I have for now. I don't see that this works in a very consistent or easy to follow way.

The #LanguagePath# stuff does seem to be an issue if you are using a language other than en-US, and to be honest, I don't see that the link it returns takes you anywhere useful. I'm not entirely sure that weather.com wants you to go directly to the alerts page(s), but want you to re-direct from the main page. It may be that there is an inconsistency with the long location id it puts in the link, and the original location code, for me it is USVA0944, and something goes haywire.


The way I do it now is:

Code: Select all

[MeasureAlerts]
Measure=String
String=[@CurrentAll]
DynamicVariables=1
IfMatch="severityCode":
IfNotMatchAction=[!HideMeter MeterAlert][!SetOption MeterAlert ImageName ""]
IfMatch2="severityCode":4
IfMatchAction2=[!HideMeter MeterAlert][!SetOption MeterAlert ImageName ""]
IfMatch3="severityCode":3
IfMatchAction3=[!SetOption MeterAlert ImageName "3.ico"][!ShowMeter MeterAlert]
IfMatch4="severityCode":2
IfMatchAction4=[!SetOption MeterAlert ImageName "2.ico"][!ShowMeter MeterAlert]
IfMatch5="severityCode":1
IfMatchAction5=[!SetOption MeterAlert ImageName "1.ico"][!ShowMeter MeterAlert]
Which will "see" all the alerts in the current day HTML, and will fire the actions for the "highest" one it sees and set the appropriate icon. It actually fires them for any severity, but the highest one "wins"...

The icon just tells you that there "are" alerts, and provides a link to the site to check them out.

I have altered it so it ignores all alerts with a severity code of "4", which eliminates the trivial stuff like small craft advisories and the like.
User avatar
SilverAzide
Posts: 700
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Some Help With Parsing weather.com

Post by SilverAzide »

Okie dokie! No worries...
DeviantArt Gadgets More...