Add Country Kitchen layer
This commit is contained in:
parent
da86da8877
commit
bfef3a2c71
4 changed files with 138 additions and 0 deletions
50
layers/chains/country-kitchen/get_data.py
Executable file
50
layers/chains/country-kitchen/get_data.py
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
|
||||
# Stolen from my machine, appears to work; sufficient and necessary to get
|
||||
# around their firewall apparently?
|
||||
UA={
|
||||
"User-Agent": 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0'
|
||||
}
|
||||
|
||||
response = requests.get('https://countrykitchenrestaurants.com/locations/', headers=UA)
|
||||
|
||||
data = re.search(r'jQuery\(document\).ready\(function\(\$\) \{var map1 = \$\("#map1"\).maps\((.*)\).data\("wpgmp_maps"\);\}\);', response.text)
|
||||
data = json.loads(data[1])
|
||||
|
||||
locations = []
|
||||
for location in data['places']:
|
||||
if "coming soon" in location['title'].lower():
|
||||
continue
|
||||
if location['title'] == "Dodgeville, WI":
|
||||
# currently location['location']['country'] == 'WI', and no location['location']['state'] -- D'oh!
|
||||
location['location']['state'] = 'WI'
|
||||
try:
|
||||
locations.append({
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [float(location['location']['lng']), float(location['location']['lat'])], # yes, [lon, lat] since it's [x, y]
|
||||
},
|
||||
"properties": {
|
||||
'address': location['address'],
|
||||
'city': location['location']['city'],
|
||||
'state': location['location']['state'],
|
||||
'zip': location['location']['postal_code'],
|
||||
},
|
||||
})
|
||||
except:
|
||||
print(location)
|
||||
|
||||
geojson = {
|
||||
"type": "FeatureCollection",
|
||||
"features": locations,
|
||||
}
|
||||
|
||||
print(len(locations), "locations found")
|
||||
|
||||
with open("data.geojson", "w") as f:
|
||||
f.write(json.dumps(geojson))
|
||||
Loading…
Add table
Add a link
Reference in a new issue