Open aberger3647 opened 1 month ago
Two difficulties: This is only going to give you a page of responses. To get every location, you'd probably need to submit repeated POSTS and change the value of paged to 2, 3, 4, ... 1a. You can reduce the number of calls necessary by using their _location_dropdown filter, if you have a rough idea of where on earth your user is. So you're not querying locations in Europe for someone in Austin
The response you get from the POST request looks just like HTML intended to be dumped/rendered onto the page. It doesn't appear to be nice clean JSON data. So you may have to use an XML or HTML parsing library
Here is a screenshot of the response. Looks like it also includes some useful pagination data
I don't know if the location data is within that template field. Maybe not. But it should at least have a link to the location's web page, which has a Google Maps link/ID: https://darksky.org/places/horseshoe-bay-texas-dark-sky-community/
There are lat/lon coordinates in the Weather paragraph which you can parse, but I don't know if they're exact to the dark sky location, or a nearby landmark. The one in the link above says:
Click here to find ideal environmental conditions for viewing the night sky in Horseshoe Bay, TX (30.53942, -98.37222). Don’t forget to plan your trip during the new moon and astronomical twilight to enhance the viewing experience!
You'd probably need to do some caching. You want to show people their nearest dark sky locations right? Aside from the initial GET request that loads the page (which already has a chunk of locations in it), the search/querying done on the site is using a POST request to their search endpoint
POST https://darksky.org/wp-json/facetwp/v1/refresh
Example body: