It is currently March 28th, 2024, 8:12 pm

⭐ Weather.com - Parsing the V3 JSON

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

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by jsmorley »

VClouds wrote: August 2nd, 2020, 10:49 am In my weather skin, when clicking the city name at the top has always opened the city page in the weather.com website.
Using this url: https://weather.com/#Language#/weather/today/l/#LocationCode#

Now after converting to the new Latitude & Longitude method instead of the weather code one, that url obviously does not work anymore.

I know that I can force the user to also enter the location code in addition to the coordinates and that will fix this, but that is something I prefer not to do as it will confuse a lot of my users.

So I wonder if there's some alternative url that uses Latitude & Longitude to open the city page in the weather.com site?
LeftMouseUpAction=[https://weather.com/weather/today/l/#Latitude#,#Longitude#]
User avatar
VClouds
Posts: 77
Joined: April 7th, 2010, 2:34 pm

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by VClouds »

jsmorley wrote: August 2nd, 2020, 11:29 am LeftMouseUpAction=[https://weather.com/weather/today/l/#Latitude#,#Longitude#]
Excellent! Thank you! :)
User avatar
Yincognito
Rainmeter Sage
Posts: 7026
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

VClouds wrote: August 2nd, 2020, 10:49 am In my weather skin, when clicking the city name at the top has always opened the city page in the weather.com website.
Using this url: https://weather.com/#Language#/weather/today/l/#LocationCode#

Now after converting to the new Latitude & Longitude method instead of the weather code one, that url obviously does not work anymore.

I know that I can force the user to also enter the location code in addition to the coordinates and that will fix this, but that is something I prefer not to do as it will confuse a lot of my users.

So I wonder if there's some alternative url that uses Latitude & Longitude to open the city page in the weather.com site?
jsmorley wrote: August 2nd, 2020, 11:29 amLeftMouseUpAction=[https://weather.com/weather/today/l/#Latitude#,#Longitude#]
Actually, you can do even better. Didn't mentioned it as the Nominatim variant of finding your latitude and longitude was independent, flexible and didn't require an API key and frankly I didn't try out these URLs until now, but one can do pretty much the same in weather.com:

Code: Select all

https://api.weather.com/v3/location/search?query=Fort Hunt&locationType=city&language=en-CA&format=json&apiKey=<ApiKey>
or, even more detailed (didn't know jsmorley's home address, so there is more than one result here too, unlike my case which is pretty much unique and outputs a single result):

Code: Select all

https://api.weather.com/v3/location/search?query=Fort Hunt, Virginia, United States&locationType=address&language=en-CA&format=json&apiKey=<ApiKey>
So basically you'll get a JSON with the possible locations, that you can parse and find out the latitude and longitude to use for the main request to the site for the weather JSON.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by jsmorley »

Yincognito wrote: August 2nd, 2020, 12:53 pm Actually, you can do even better. Didn't mentioned it as the Nominatim variant of finding your latitude and longitude was independent, flexible and didn't require an API key and frankly I didn't try out these URLs until now, but one can do pretty much the same in weather.com:

Code: Select all

https://api.weather.com/v3/location/search?query=Fort Hunt&locationType=city&language=en-CA&format=json&apiKey=<ApiKey>
or, even more detailed (didn't know jsmorley's home address, so there is more than one result here too, unlike my case which is pretty much unique and outputs a single result):

Code: Select all

https://api.weather.com/v3/location/search?query=Fort Hunt, Virginia, United States&locationType=address&language=en-CA&format=json&apiKey=<ApiKey>
So basically you'll get a JSON with the possible locations, that you can parse and find out the latitude and longitude to use for the main request to the site for the weather JSON.
Yeah, there are a lot of ways to get the latitude / longitude for a given location.

This is probably my favorite:

https://forum.rainmeter.net/viewtopic.php?f=118&t=34628&start=530#p180890

As then you can have a link like:

https://www.google.com/maps/search/#Latitude#,#Longitude#

in your skin, and it will jump straight to your actual house in Google Maps, confirming that the skin is in fact using the right location.
User avatar
Yincognito
Rainmeter Sage
Posts: 7026
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

jsmorley wrote: August 2nd, 2020, 12:59 pm Yeah, there are a lot of ways to get the latitude / longitude for a given location.
Yep, but it just occured to me that I might have misunderstood VClouds' question in the first place... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7026
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

jsmorley wrote: August 2nd, 2020, 12:59 pm Yeah, there are a lot of ways to get the latitude / longitude for a given location.

This is probably my favorite:

https://forum.rainmeter.net/viewtopic.php?f=118&t=34628&start=530#p180890

As then you can have a link like:

https://www.google.com/maps/search/#Latitude#,#Longitude#

in your skin, and it will jump straight to your actual house in Google Maps, confirming that the skin is in fact using the right location.
Indeed.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
VClouds
Posts: 77
Joined: April 7th, 2010, 2:34 pm

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by VClouds »

Yincognito wrote: August 2nd, 2020, 1:02 pm Yep, but it just occured to me that I might have misunderstood VClouds' question in the first place... :???:
Yes, I just needed a simple weather.com link that uses the lat and long coordinates that are already present in the variables file to display the user's city weather.
jsmorley provided exactly what I was looking for.

But thanks for trying to help. :D
User avatar
Yincognito
Rainmeter Sage
Posts: 7026
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

VClouds wrote: August 2nd, 2020, 1:20 pm Yes, I just needed a simple weather.com link that uses the lat and long coordinates that are already present in the variables file to display the user's city weather.
jsmorley provided exactly what I was looking for.

But thanks for trying to help. :D
Yep, sorry 'bout that. :oops:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by jsmorley »

I have added .inc files for up to 15 days of "Pollen forecasts"

WeatherComJSONPollen.inc
WeatherComJSONPollen10Day.inc
WeatherComJSONPollen7Day.inc
WeatherComJSONPollen5Day.inc
WeatherComJSONPollen3Day.inc

This forecasts values for Grass / Tree / Ragweed pollen levels.

I also corrected an issue with WeatherComJSONAlerts.inc that would produce an error in the log if there were no current alerts on the site.

Get the new .rmskin in the first post of this tread.
thohan
Posts: 7
Joined: April 17th, 2016, 7:38 am

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by thohan »

I was looking at the new Pollen files and noticed that the UserAgent was for Firefox 78 while my browser was on 79 (I assume jsmorley 's is also updated) and this started me thinking the a variable #userAgent# in the WeatherComJSONVariables.inc file might be a good idea.

Between the expanding number of .inc files, the possibility of a security problem in a specific version of the browser, and just wanting to keep the userAgent up to date with the latest and greatest version being used by the user I think that this might be a way to set up for an easy fix in the future if this problem arose.

in any case I am simply agog and appreciative of al the work and problem solving involved in getting the weather feed up and running. This makes my transition from DarkSky to weather.com much easier and I thank you.