maps.chandlerswift.com/layers/chains/raising-canes/get_data.py

47 lines
1.7 KiB
Python
Raw Normal View History

2024-03-09 19:54:18 -06:00
#!/usr/bin/env python3
import requests
import json
print("Searching for Raising Cane's locations")
response = requests.get('https://raisingcanes.com/page-data/sq/d/3976656178.json').json()
stores = []
for s in response['data']['allPrismicStoreLocation']['nodes']:
if s['uid'] == 'ara2': # Not sure what's up with this one: https://raisingcanes.com/locations/ara2/
continue
elif s['uid'] == 'c524': # Null island? https://raisingcanes.com/locations/c524/
s['data']['coordinates'] = {
"longitude": -111.9811399,
"latitude": 40.5447361,
}
stores.append({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [float(s['data']['coordinates']['longitude']), float(s['data']['coordinates']['latitude'])], # yes, [lon, lat] since it's [x, y]
},
"properties": {
'name': s['data']['external_location_data']['displayName'],
'nickname': s['data']['external_location_data']['nickname'],
'address': s['data']['external_location_data']['address1'],
'city': s['data']['external_location_data']['city'],
'state': s['data']['external_location_data']['state'],
'zip': s['data']['external_location_data']['postal_code'],
'website': f"https://raisingcanes.com/locations/{s['uid']}",
'opened': s['data']['external_location_data']['birthdate'],
'hours': s['data']['external_location_data']['hours'],
},
})
print(f"""{len(stores)} locations found""")
geojson = {
"type": "FeatureCollection",
"features": stores,
}
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))