Add Michaels

Requested-By: Käthe Swift
main
Chandler Swift 2024-04-28 01:05:55 -05:00
parent 308ec72569
commit dd90c2670f
Signed by: chandlerswift
GPG Key ID: A851D929D52FB93F
4 changed files with 103 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import culversLayer from './culvers/layer.js';
import krispyKremeLayer from './krispy-kreme/layer.js';
import kwikTripLayer from './kwik-trip/layer.js';
import menardsLayer from './menards/layer.js';
import michaelsLayer from './michaels/layer.js';
import milwaukeeBurgerCompanyLayer from './milwaukee-burger-company/layer.js';
import punchPizzaLayer from './punch-pizza/layer.js';
import raisingCanesLayer from './raising-canes/layer.js';
@ -32,6 +33,10 @@ const chains = {
name: "Menards",
layer: menardsLayer,
},
{
name: "Michaels",
layer: michaelsLayer,
},
{
name: "Milwaukee Burger Company",
layer: milwaukeeBurgerCompanyLayer,

View File

@ -0,0 +1,57 @@
#!/usr/bin/env python3
import requests
import json
from bs4 import BeautifulSoup
# 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'
}
locations = []
response = requests.get('https://locations.michaels.com/', headers=UA)
soup = BeautifulSoup(response.text, 'html.parser')
for state in soup.select('#content ul.state_list li a'):
print(" ", state['href'])
response = requests.get(state['href'], headers=UA)
soup = BeautifulSoup(response.text, 'html.parser')
for city in soup.select('#cities ul.city_list li > a'):
print(" ", city['href'])
response = requests.get(city['href'], headers=UA)
soup = BeautifulSoup(response.text, 'html.parser')
for location in soup.select('#locations > ul > li > a'):
print(" ", location['href'])
response = requests.get(location['href'], headers=UA)
soup = BeautifulSoup(response.text, 'html.parser')
scripts = [scr.text for scr in soup.find_all('script') if 'latitude' in scr.text] # TODO: filter this better??
data = json.loads(scripts[0])
locations.append({
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [data['geo']['longitude'], data['geo']['latitude']], # yes, [lon, lat] since it's [x, y]
},
"properties": {
'address': data['address']['streetAddress'],
'city': data['address']['addressLocality'],
'state': data['address']['addressRegion'],
'zip': data['address']['postalCode'],
'country': data['address']['addressCountry'],
'url': data['url'],
'website': location['href'],
},
})
geojson = {
"type": "FeatureCollection",
"features": locations,
}
print(len(locations), "locations found")
with open("data.geojson", "w") as f:
f.write(json.dumps(geojson))

View File

@ -0,0 +1,24 @@
import VectorLayer from 'ol/layer/Vector';
import {Vector as VectorSource} from 'ol/source.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import {Style} from 'ol/style.js';
import Icon from 'ol/style/Icon.js';
import url from './data.geojson?url'; // TODO: remove `?url`?
import pin from './pin.svg?url'; // TODO: remove `?url`?
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: url,
format: new GeoJSON,
}),
style: new Style({
image: new Icon({
anchor: [0.5, 1],
src: pin,
}),
}),
});
export default vectorLayer;

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 384 512"
width="40px"
height="30px"
version="1.1"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="m 384,192 c 0,87.4 -117,243 -168.3,307.2 -12.3,15.3 -35.1,15.3 -47.4,0 C 116.1,435 0,279.4 0,192 0,85.96 85.96,0 192,0 245.96029,0 294.73775,22.275796 329.62577,58.136607 363.27205,92.721042 384,139.94065 384,192 Z"
style="fill:#CF1F2E;fill-opacity:1" />
<path d="M42.8269 34.4669C42.0257 31.4159 42.523 25.1244 43.0111 21.4416C43.444 18.3234 44.0945 15.8593 44.6634 13.7042L44.6634 13.7042L44.6634 13.7041L44.6634 13.7041L44.6635 13.704L44.6635 13.704L44.6635 13.7039L44.6635 13.7039C45.305 11.2738 45.8428 9.23682 45.8477 7.0984C45.8477 5.22088 45.2491 1.33044 41.0587 1.16796C30.7162 0.824953 26.9034 25.4765 26.3877 28.9607C26.3138 28.4039 26.2803 26.9362 26.2356 24.9794C26.1519 21.3208 26.0292 15.9522 25.5312 11.6297C24.4352 1.8269 22.2709 1.26725 20.1343 1.10478C13.0632 0.593243 11.9937 12.7736 11.9394 25.5282C11.8447 22.7354 11.3988 19.4787 9.5708 17.488C8.21698 16.0166 6.12638 16.1611 7.51704 18.1198C7.59304 18.2206 7.67121 18.3809 7.75576 18.5544C7.8454 18.7382 7.9422 18.9368 8.0512 19.0947C9.31808 20.9679 9.86261 25.4935 10.3726 29.732C10.9414 34.4597 11.4673 38.8302 12.9047 38.7635C13.7612 38.7635 15.0506 38.3844 14.94 34.828C14.6177 24.1044 15.4466 4.90495 19.1765 4.8869C21.9015 4.8869 22.3308 13.9599 22.7126 22.0279C22.8844 25.6575 23.0465 29.0837 23.4037 31.3888C24.0484 35.1529 28.0086 35.4688 29.2887 30.1161C29.7267 28.2166 30.0542 26.4981 30.3667 24.8584C31.2303 20.3265 31.9793 16.3958 34.6303 10.9076C39.4286 0.978404 43.3887 4.25504 41.6849 11.1513C41.5847 11.5364 41.4613 11.9806 41.3227 12.4791L41.3225 12.4796C40.1879 16.562 38.0407 24.287 39.3457 33.0227C39.7693 35.875 41.6481 39.4857 43.0295 38.7094C43.7917 38.2886 43.4622 37.0347 42.8892 34.8544L42.7993 34.512L42.8269 34.4669Z" fill="white" transform="scale(7.5) translate(-2,5)"/>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB