At the end of the day, it might indeed be that the most accurate way is to use the lat,long as input to the URL. You may not like the displayName it comes up with, but I think it will use the closest "observation station" and be correct.
For instance if I go to Google Maps and find "Harlem" in New York City / Manhattan, then use the lat,long returned in the Google Maps URL as input to weather.com, it uses a displayName of "Manhattan", which is close enough. I assume the actual weather will be as good as it can do for an area as specific as "Harlem". As it turns out, there is no locid that can be matched on the name "Harlem" in New York. Georgia, sure, Montana, yep. New York, no.
I'm betting that in this case, the "first" set of location information will be spotty at best.
It is currently September 8th, 2024, 4:35 am
⭐ Weather.com - Parsing the V3 JSON
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
-
- Rainmeter Sage
- Posts: 2734
- Joined: March 23rd, 2015, 5:26 pm
Re: ⭐ weather.com - Parsing the JSON
Yes! This is the exact scenario I run into, even though my podunk little town has 100th the population and size of New York City.
The good news for us is that the TWC URL still allows short codes, long codes, and lat/longs without much complaining, so users have the option of whichever they prefer. This is a much nicer API than Dark Sky, which is lat/long or nothing (not to mention TWC has way better data).
The good news for us is that the TWC URL still allows short codes, long codes, and lat/longs without much complaining, so users have the option of whichever they prefer. This is a much nicer API than Dark Sky, which is lat/long or nothing (not to mention TWC has way better data).
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ weather.com - Parsing the JSON
I'm just not convinced there is an accurate way to get lat,long for your location with WebParser. Yes, I know there are sites that will return what it detects as your location, but they only work right in a "browser", which can provide the far more accurate "GeoLocation" information your browser gets. With WebParser, which isn't a browser, and can't answer any questions the site might be asking, (permissions being one of them) I suspect you will get what is returned for your raw IP Address, which will be the closest "point of presence" for your ISP. For me, that is in Chantilly, Virginia, which isn't even close to where my house is. It's like a 30-minute drive.
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: ⭐ weather.com - Parsing the JSON
I remember you mentioning it somewhere in your posts (and it's probably mentioned also in some of the docs I linked to), but I don't seem to find that post at the moment, so I'll ask again: what is the URL format when using LAT and LONG instead of a location code?
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: ⭐ weather.com - Parsing the JSON
https://weather.com/en-US/weather/today/l/38.7235031,-77.0663437Yincognito wrote: ↑February 20th, 2020, 3:50 pm I remember you mentioning it somewhere in your posts (and it's probably mentioned also in some of the docs I linked to), but I don't seem to find that post at the moment, so I'll ask again: what is the URL format when using LAT and LONG instead of a location code?
Pretty much any granularity in the decimal portions of the numbers is supported.
https://weather.com/en-US/weather/today/l/38.724,-77.066
The more granular lat / long is, the more accurate it is, but at some point that has diminishing returns on something as broad as the weather. The weather in my front yard is very similar to the weather in my back yard, or the 7-11 down the street, or more to the point, the closest observation station to me.
What weather.com "returns" seems to always be at most to three decimal places.
At the end of the day, what I want is to zero in on the observation station that is closest to me, which is what measures the weather, then have it "display" my exact location in displayName. Yes, that is going to be somewhat "cosmetic" and "feel good", but that is the best result for me.
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: ⭐ weather.com - Parsing the JSON
Thanks. What's interesting is that the 1st subsection of "Location" displays here the neighborhood and a non-null locale4 field, while the 2nd subsection doesn't. I didn't have such an example to analyze before.jsmorley wrote: ↑February 20th, 2020, 3:52 pmhttps://weather.com/en-US/weather/today/l/38.724,-77.066
Now, I'm trying to find a free service that can provide an accurate lat/long for a location that's present in the URL. So far, most of them work by "Javascripting" the location one enters in a search field on the page, rather than use a part of an URL query to set the location.
EDIT: Found one: GeoCodeXYZ. It seems free of charge, fast and the output can be either xml, json, etc. I can get the lat and long of your location just by entering this URL, and it also has a nice field called confidence to show the likeness of the provided coordinates being correct for a (possibly, non-unique) location. It works for my city as well, just by entering its name, without any other info (granted, there aren't many "duplicate" locations for my city name).
-
- Rainmeter Sage
- Posts: 2734
- Joined: March 23rd, 2015, 5:26 pm
Re: ⭐ weather.com - Parsing the JSON
Here's the API you are looking for
https://nominatim.openstreetmap.org/search?city=Fort%20Hunt&format=xml&addressdetails=1
Search for the city/place, get the lat/long. But it just gives you the center of town. If you want more accurate results, I don't know of an API. I just have been using Google Maps and dropping a pin.
![Smiler :)](./images/smilies/ab.gif)
https://nominatim.openstreetmap.org/search?city=Fort%20Hunt&format=xml&addressdetails=1
Search for the city/place, get the lat/long. But it just gives you the center of town. If you want more accurate results, I don't know of an API. I just have been using Google Maps and dropping a pin.
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: ⭐ weather.com - Parsing the JSON
That's even better, as it's faster that what I found.SilverAzide wrote: ↑February 20th, 2020, 4:52 pm Here's the API you are looking for![]()
https://nominatim.openstreetmap.org/search?city=Fort%20Hunt&format=xml&addressdetails=1
Search for the city/place, get the lat/long. But it just gives you the center of town. If you want more accurate results, I don't know of an API. I just have been using Google Maps and dropping a pin.
![Wink ;-)](./images/smilies/innuendo.gif)
-
- Rainmeter Sage
- Posts: 2734
- Joined: March 23rd, 2015, 5:26 pm
Re: ⭐ weather.com - Parsing the JSON
Looks like you can drill down to the street level....
https://nominatim.openstreetmap.org/search?q=Fort+Hunt+Park%2C+Fort+Hunt%2C+VA&format=xml&addressdetails=1
Docs:
https://nominatim.org/release-docs/latest/api/Search/
https://nominatim.openstreetmap.org/search?q=Fort+Hunt+Park%2C+Fort+Hunt%2C+VA&format=xml&addressdetails=1
Docs:
https://nominatim.org/release-docs/latest/api/Search/
-
- Rainmeter Sage
- Posts: 8030
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: ⭐ weather.com - Parsing the JSON
Indeed. If I simply entered the road / avenue name in my case, it put the actual road name in the "artwork" field. If I entered the avenue name preceeded by the word for "avenue" in my language, it gave me 2 results, so in the latter case I had to add &limit=1 to the query, for easier (potential) parsing.SilverAzide wrote: ↑February 20th, 2020, 5:08 pm Looks like you can drill down to the street level....
https://nominatim.openstreetmap.org/search?q=Fort+Hunt+Park%2C+Fort+Hunt%2C+VA&format=xml&addressdetails=1
Docs:
https://nominatim.org/release-docs/latest/api/Search/