Right. Thanks. This might be useful if you wanted a combination not supported by just using Language. Like French and Fahrenheit.JelleDekkers wrote: ↑June 20th, 2020, 9:30 am Adding "?temp=" to the URL makes it possible to manually choose the units
Possible values for the parameter are "c", "f", "m", or "e".
I found out by clicking the little "weather.com" link below the widget when searching for "weather" on Google.
It is currently September 20th, 2024, 7:31 am
⭐ Weather.com - Parsing the V3 JSON
-
- Developer
- Posts: 22747
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON
-
- Rainmeter Sage
- Posts: 8188
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: ⭐ Weather.com - Parsing the V3 JSON
Yep, I guess it looks alright. In my case, besides dealing with the quotes later (which I do as well), I was also interested in making the "data" capture work whatever the nature of the data was, so that I wouldn't have to write / use another pattern for strings or whatever else the data would look like. That was the main reason why I ended up with what I posted earlier. The way you approach things, while perfectly fine, requires: a) knowing the kind of data you look for, and b) using a different pattern in the case of strings ... especially if those strings contain commas (like in the case of some of the narratives), because an ungreedy regex will stop at the first comma and discard the rest of the string. I know OnyxBlack already handled that and his method is probably fine as well, but I always like things to be the "one size fits all" type (however discredited this approach is nowadays), to eliminate redundancy and doing the same work again for a different scenario.jsmorley wrote: ↑June 20th, 2020, 5:29 am So this was about as simple as I could make the regular expression to capture one "pair" of values for a day, the "day" and "night" values:
"iconCode":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]]
[...]
This should properly account for the JSON format of:
"iconCode":[null,29,4,27,38,29,4,29,38,29,38,47,30,29,34,33,30,29,30,29,37,47,38,47,38,47,30,47,38,47]
[...]
Again, Strings are enclosed in "quotes" and numbers are not, but that doesn't matter at all. Deal with the "quotes" later.
Anyway, that's just me, and by no means I try to convince anyone to do as I do - just wanted to clarify the reasoning behind it. As long as the stuff is functional, any method is valid - it's just that personally I don't like to work twice when I can work once and be done with it.
-
- Developer
- Posts: 22747
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON
Drat... You know, you are right. This isn't going to handle commas in the two possible "Narratives" per day. I'll have to tweak it again.Yincognito wrote: ↑June 20th, 2020, 12:54 pm Yep, I guess it looks alright. In my case, besides dealing with the quotes later (which I do as well), I was also interested in making the "data" capture work whatever the nature of the data was, so that I wouldn't have to write / use another pattern for strings or whatever else the data would look like. That was the main reason why I ended up with what I posted earlier. The way you approach things, while perfectly fine, requires using a different pattern in the case of strings ... especially if those strings contain commas (like in the case of some of the narratives), because an ungreedy regex will stop at the first comma and discard the rest of the string. I know OnyxBlack already handled that and his method is probably fine as well, but I always like things to be the "one size fits all" type (however discredited this approach is nowadays), to eliminate redundancy and doing the same work again for a different scenario.
Anyway, that's just me, and by no means I try to convince anyone to do as I do - just wanted to clarify the reasoning behind it. As long as the stuff is functional, any method is valid - it's just that personally I don't like to work twice when I can work once and be done with it.
-
- Posts: 46
- Joined: December 5th, 2017, 5:58 pm
Re: ⭐ Weather.com - Parsing the V3 JSON
thanx 4 answers. i got something not all. how to make this working that way in one regexp:
"precipChance":[null,100,10,60,60,80,80,80,100,80,80,60,40,50,50,50],"precipType":[null,"rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],
"precipChance":[null,100,10,60,60,80,80,80,100,80,80,60,40,50,50,50],"precipType":[null,"rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],
-
- Developer
- Posts: 22747
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON
Edit June 20, 2020 - Tweaked the regular expression to account for the fact that there can be commas in several of the fields, like the "narrative" entries. Also added a missing WindPhrase field to the measures.
Get the .rmskin in the first post of this thread.
Get the .rmskin in the first post of this thread.
-
- Developer
- Posts: 22747
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON
I think the best thing is for you to take a look at the file WeatherComJSONMeasures.inc that is included with the .rmskin.nikko wrote: ↑June 20th, 2020, 2:29 pm thanx 4 answers. i got something not all. how to make this working that way in one regexp:
"precipChance":[null,100,10,60,60,80,80,80,100,80,80,60,40,50,50,50],"precipType":[null,"rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],
-
- Rainmeter Sage
- Posts: 8188
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: ⭐ Weather.com - Parsing the V3 JSON
But jsmorley's skin and his .inc files already get that. Why would you need to bother with the regexes yourself?nikko wrote: ↑June 20th, 2020, 2:29 pm thanx 4 answers. i got something not all. how to make this working that way in one regexp:
"precipChance":[null,100,10,60,60,80,80,80,100,80,80,60,40,50,50,50],"precipType":[null,"rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain","rain"],
Take a look here and use the corresponding measures from the long quoted list in that post in your meters - that's all. For example, use [@ForecastDay2DayPrecipitationPercent] for the precipitation chance from the daytime part of the 2nd forecast day, and [@ForecastDay2DayPrecipitationType] for the precipitation type from the same period. Change the number from 2 to whatever day you want (max. 15) and if you want the values for the nighttime of that day, just replace the 2nd occurence of 'Day' in the measure name(s) with 'Night'.
-
- Developer
- Posts: 22747
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON
Yes, the current RegExp to get all the different types of "forecast" information, for one day (Day 1 or "today" in this case) for both "day" and "night" looks like this:
This is why you probably DON'T really want to parse the JSON yourself, but just use the .inc @Include files I provide. This is not a wheel most of you are likely to enjoy re-inventing...RegExp=(?siU)"getSunV3DailyForecastUrlConfig":.*"duration:15day;.*"dayOfWeek":\[(?:.*[,|\]]){0}(.*)[,|\]].*"narrative":\[(?:null,|".*"[,|\]]){0}(null|".*")[,|\]].*"qpf":\[(?:.*[,|\]]){0}(.*)[,|\]].*"qpfSnow":\[(?:.*[,|\]]){0}(.*)[,|\]].*"sunriseTimeLocal":\[(?:.*[,|\]]){0}(.*)[,|\]].*"sunsetTimeLocal":\[(?:.*[,|\]]){0}(.*)[,|\]].*"temperatureMax":\[(?:.*[,|\]]){0}(.*)[,|\]].*"temperatureMin":\[(?:.*[,|\]]){0}(.*)[,|\]].*"cloudCover":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"dayOrNight":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"daypartName":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"iconCode":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"narrative":\[(?:null,|".*"[,|\]]){0}(null|".*")[,|\]](null|".*")[,|\]].*"precipChance":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"precipType":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"qpf":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"qpfSnow":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"relativeHumidity":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"snowRange":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"temperature":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"temperatureHeatIndex":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"temperatureWindChill":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"thunderCategory":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"thunderIndex":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"uvDescription":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"uvIndex":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"windDirection":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"windDirectionCardinal":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"windPhrase":\[(?:null,|".*"[,|\]]){0}(null|".*")[,|\]](null|".*")[,|\]].*"windSpeed":\[(?:.*[,|\]]){0}(.*),(.*)[,|\]].*"wxPhraseLong":\[(?:null,|".*"[,|\]]){0}(null|".*")[,|\]](null|".*")[,|\]].*"wxPhraseShort":\[(?:null,|".*"[,|\]]){0}(null|".*")[,|\]](null|".*")[,|\]]
-
- Developer
- Posts: 22747
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ Weather.com - Parsing the V3 JSON
I made a couple more small tweaks, be sure to get the latest .rmskin.
-
- Posts: 46
- Joined: December 5th, 2017, 5:58 pm
Re: ⭐ Weather.com - Parsing the V3 JSON
tnanx for explanation y and js. one more question can you explain this most complex thing;
wxPhraseLong":\[(?:null,|".*"[,|\]]){2}(null|".*")[,|\]](null|".*")[,|\]].*
wxPhraseLong":\[(?:null,|".*"[,|\]]){2}(null|".*")[,|\]](null|".*")[,|\]].*