maps.chandlerswift.com/layers/chains/waffle-house/get_data.py

42 lines
1.0 KiB
Python
Raw Normal View History

2023-07-24 22:44:54 -05:00
#!/usr/bin/env python3
import requests
import re
import json
res = requests.get('https://locations.wafflehouse.com/')
content = res.text
locations = re.search(r'<script id="__NEXT_DATA__" type="application/json">(.*)</script>', content)[1]
locations = json.loads(locations)['props']['pageProps']['locations']
stores = []
for location in locations:
stores.append({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [float(location['longitude']), float(location['latitude'])], # yes, [lon, lat] since it's [x, y]
},
"properties": {
'address': location['addressLines'][0].title(),
'city': location['city'].title(),
'state': location['state'],
'zip': location['postalCode'],
'website': location['websiteURL'],
},
})
geojson = {
"type": "FeatureCollection",
"features": stores,
}
with open("data.geojson", "w") as f:
2023-07-24 22:44:54 -05:00
f.write(json.dumps(geojson))
print(f"{len(locations)} locations found")