It is currently February 20th, 2020, 6:51 pm

⭐ weather.com - Some Tools for Parsing

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

Re: ⭐ Some help with parsing weather.com

Post by jsmorley »

balala wrote:
January 21st, 2020, 4:27 pm
One possible solution of the question in cause would be to manually convert the units. As far as I know you can easily get the temperature unit in which the values are returned in the skin. One single properly created Calc measure can convert the Celsius to Fahrenheit or vice-versa, Fahrenheit to Celsius. I suppose this isn't too hard to be done.
Certainly... Of course there are potentially lots of temperatures in a skin you would need this for, and this gets a bit more involved and in some cases more complicated, to convert wind speed, barometric pressure and sunrise/sunset times.

To simply change F to C or C to F, I would be tempted to use Inline Lua to do this, rather than a boatload of Calc measures.

I personally don't recommend it. If you are using a language like French, I can't see any reason why you would want the temperature(s) in Fahrenheit, the wind speed in mph, the barometric pressure in inHg or the times in 12-hour time. The only thing that makes much sense to me is if you are using English, but want the units in metric cause you are a child of the world. Then you just use the language code en-GB or en-AU instead of en-US.



en-US:
enUS.png


en-AU:
enAU.png
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 9729
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ⭐ Some help with parsing weather.com

Post by balala »

jsmorley wrote:
January 21st, 2020, 4:29 pm
Of course there are potentially lots of temperatures in a skin you would need this for, and this gets a bit more involved and in some cases more complicated, to convert wind speed, barometric pressure and sunrise/sunset times.

To simply change F to C or C to F, I would be tempted to use Inline Lua to do this, rather than a boatload of Calc measures.
Depends on the skin. My idea (after I posted my previous reply), same as yours, was a Lua code with Inline functions. Such a code could also convert wind speeds, pressures and so on (even times).
jsmorley wrote:
January 21st, 2020, 4:29 pm
If you are using a language like French, I can't see any reason why you would want the temperature(s) in Fahrenheit, the wind speed in mph, the barometric pressure in inHg and the times in 12-hour time. One thing you can do, if you are using English, but want the units in metric, is to use the language code en-GB instead of en-US.
Completely agree. As far as I know the imperial units are used nowhere except for the USA, Liberia and Myanmar. The idea was not why anyone would do this, but that it can be done. Although I didn't try it yet, I think it can be done.
User avatar
SilverAzide
Posts: 690
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Some help with parsing weather.com

Post by SilverAzide »

jsmorley wrote:
January 19th, 2020, 1:36 am
Feel free to ask questions...
Just in case you want more feedback. ;-)
I know you are not too keen on dealing with weather alerts (other than the fact that there IS one or more), but the regexps for alerts DO seem to be working with a couple of exceptions.

First, since no alert URLs are being captured (unfortunately), you COULD dispense with the #LanguagePath# stuff and just replace it with ".*". It would be a cool addition to grab the alert URL to allow skins to point users to the alert page.

SevereAlert doesn't appear to grab anything; perhaps I misunderstand its purpose. A modified version with captures is:

Code: Select all

SevereAlert=(?siU)(?(?=.*<a class="priority bg-alert-.*" href=".*/weather/alerts/localalerts/l/.*").* title=".*" data-from-string=".*" className="priority bg-alert-(.)"><div class="title text text-overflow" className="title text text-overflow"><span class="warning-text" className="warning-text">(.*)</span><span class="timestamp" className="timestamp">(.*)</span>)

1 => 4
2 => Wind Chill Advisory
3 => From 12:00am EST, Wed Jan 22 until 10:00am EST, Wed Jan 22
4 => 
PriorityAlert works fine as:

Code: Select all

PriorityAlert=(?siU)(?(?=.*<div class="gm-alerts-time).*"><a class="priority bg-alert-.*" href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*

1 => 2
2 => Freeze Warning
3 => From 12:00am EST, Wed Jan 22 until 10:00am EST, Wed Jan 22
4 => 
The ginormous ALERT regexp (returns something like 14 alerts in one go) works fine as:

Code: Select all

ALERT=(?siU)(?(?=.*<div id=".*-SevereAlertBar).*-.*"><div><div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*(?(?=.*<a class="priority bg-alert-.*").* href=".*/weather/alerts/localalerts/.* className="priority bg-alert-(.*)">.*<span class="warning-text" className="warning-text">(.*)</span>).*(?(?=.*<span class="timestamp").* className="timestamp">(.*)</span></div>).*

1 => 4
2 => Wind Chill Advisory
3 => From 12:00am EST, Wed Jan 22 until 10:00am EST, Wed Jan 22
4 => 2
5 => Freeze Warning
6 => From 12:00am EST, Wed Jan 22 until 10:00am EST, Wed Jan 22
7 =>
The IconAlert regexp doesn't appear to capture anything either, so not sure what this is for.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20269
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Some help with parsing weather.com

Post by jsmorley »

I just don't think I'm going to wade any deeper into alerts in the short-term. The fact that xenium said that the HTML for those changed several times in the last year makes my skin crawl a little. It's my personal opinion, but I think just knowing that there are alerts, and what value the most severe is, is good enough for me to click on it and see the details on the website. I don't think I need something on the desktop that shows me the contents of all 4 or 5 alerts you are going to get when we get a dusting of snow here in Virginia.

P.S. The RegExp that don't (capture) anything can still indicate that something exists just because they work.
User avatar
SilverAzide
Posts: 690
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Some help with parsing weather.com

Post by SilverAzide »

jsmorley wrote:
January 21st, 2020, 11:11 pm
I just don't think I'm going to wade any deeper into alerts in the short-term. The fact that xenium said that the HTML for those changed several times in the last year makes my skin crawl a little. It's my personal opinion, but I think just knowing that there are alerts, and what value the most severe is, is good enough for me to click on it and see the details on the website. I don't think I need something on the desktop that shows me the contents of all 4 or 5 alerts you are going to get when the weather is bad.
Gotcha... very understandable. Just figured I'd give some feedback in case you or someone wanted to give alerts a try using the template.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20269
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 21st, 2020, 11:19 pm
Gotcha... very understandable. Just figured I'd give some feedback in case you or someone wanted to give alerts a try using the template.
I'm going to give what I have some time to settle in and be sure it is reliable...

Most people just want a simple weather skin that shows the current weather and a day or two out. For those who want to go for the full blown weather station, they are welcome to figure it out... Phases of the moon for the next week? Really?
User avatar
SilverAzide
Posts: 690
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Some help with parsing weather.com

Post by SilverAzide »

jsmorley wrote:
January 21st, 2020, 11:21 pm
I'm going to give what I have some time to settle in and be sure it is reliable...
Good idea... And in case you want more feedback, this "Weather Template" project is a freakin' godsend, so everyone deserves kudos for this. Electic-tech's idea for doing quick ports via switching WebParsers to String measures to "wrap" the measures in the template is genius as well.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20269
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 21st, 2020, 11:26 pm
Good idea... And in case you want more feedback, this "Weather Template" project is a freakin' godsend, so everyone deserves kudos for this. Electic-tech's idea for doing quick ports via switching WebParsers to String measures to "wrap" the measures in the template is genius as well.
Yeah, this is definitely a collaborative effort.
xenium
Posts: 481
Joined: January 4th, 2018, 9:52 pm

Re: ⭐ Some help with parsing weather.com

Post by xenium »

jsmorley wrote:
January 21st, 2020, 11:21 pm
Phases of the moon for the next week? Really?
I added yesterday for W10WEntp and info for the Moon.
Attention, special measures are required with certain options.
See in the skin the measures for the Moon and in the Meters section, see the tooltip for the first icon from Forecast
iron2000
Posts: 11
Joined: June 6th, 2011, 3:47 am

Re: ⭐ Some help with parsing weather.com

Post by iron2000 »

jsmorley wrote:
January 20th, 2020, 3:41 pm
I'm not quite sure why you would want the temperature in Celsius, but have the rest of the information using Imperial units, like miles per hour and inches of mercury and 12-hour time. However, to each his own, that is rule one in Rainmeter...
My skin only uses temperature and weather condition.
And it already has a C or F option so I'm just fixing it back to work.

Anyway I used the LUA script you linked.
First time using script took some fiddling but its working.