initial meijer support

This commit is contained in:
steven 2025-05-05 02:45:39 -04:00
parent e6a5cb6d9c
commit e94e686b43
2 changed files with 21 additions and 6 deletions

20
app.py
View file

@ -17,8 +17,8 @@ def favicon():
@app.route("/samsclub.csv")
@cache.cached(timeout=1800)
def sams():
url='https://www.samsclub.com/api/node/vivaldi/browse/v2/clubfinder/list?distance=10000&nbrOfStores=1000&singleLineAddr=10001'
headers={'User-Agent':'Mozilla/5.0','Accept-Encoding':'ztsd'}
url='https://www.samsclub.com/api/node/vivaldi/browse/v2/clubfinder/list?distance=9999&nbrOfStores=999&singleLineAddr=1'
headers={'User-Agent':'Mozilla/5.0'}
sams=httpx.get(url,headers=headers,timeout=10).json()
result=[]
for s in sams:
@ -31,7 +31,7 @@ def sams():
@cache.cached(timeout=1800)
def costco():
url='https://www.costco.com/AjaxWarehouseBrowseLookupView?hasGas=true&populateWarehouseDetails=true'
headers={'Accept':'*/*','Accept-Encoding':'gzip,deflate,br,zstd','Accept-Language':'en','Referer':'costco.com','Sec-Fetch-Mode':'cors','User-Agent':'Mozilla/5.0 Firefox/140.0'}
headers={'Accept-Language':'en','Referer':'costco.com','Sec-Fetch-Mode':'cors','User-Agent':'Mozilla/5.0 Firefox/140.0'}
costco=httpx.Client(http2=True).get(url,headers=headers,timeout=60).json()[1:]
result=[]
for s in costco:
@ -39,3 +39,17 @@ def costco():
p={g:int(float(s['gasPrices'][g])*100) for g in ['regular','premium']}
result.append(f"{p['regular']},{p['premium']},{s['latitude']},{s['longitude']},{s['displayName']}")
return "\n".join(result)
@app.route("/meijer.csv")
@cache.cached(timeout=1800)
def meijer():
url='https://www.meijer.com/bin/meijer/store/search/proximity?latitude=38.3&longitude=-85.7&miles=20&numToReturn=10'
headers={'User-Agent':'Firefox/140'}
meijer=httpx.get(url,headers=headers).json()['store']
result=[]
for s in meijer:
p=httpx.get(f"https://www.meijer.com/bin/meijer/store/hours?store-id={s['UnitId']}",headers=headers).json()
if 'fuelPrices' in p:
p={g['FuelType'].split('-')[0]:int(g['FuelPrice']*100) for g in p['fuelPrices']}
result.append(f"{p['UNL']},{p['PREM']},{s['latitude']},{s['longitude']},{s['UnitId']}")
return "\n".join(result)

View file

@ -14,16 +14,17 @@
color:black;
text-decoration:none;
}
.samsclub,.costco{
.samsclub,.costco,.meijer{
display:flex;
border-radius:33%;
text-align:center;
align-items:center;
font-size:14px;
font-weight:bold;
}
.samsclub,.costco{border-radius:33%;}
.samsclub{background-color:rgba(0,103,160,0.5);}
.costco{background-color:rgba(227,42,54,0.5);}
.meijer{background-color:rgba(221,19,33,0.5);}
</style>
</head>
<body>
@ -31,7 +32,7 @@
<script>
let map=L.map("map",{center:[38.243,-85.647],zoom:11,layers:[L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")]});
let layerControl=L.control.layers(null,null,{collapsed:false}).addTo(map);
let chains={"Sam's Club":"https://www.samsclub.com/local/fuel-center/-/X","Costco":"https://www.costco.com/warehouse-locations-X.html#:~:text=Gas%20Station"};
let chains={"Sam's Club":"https://www.samsclub.com/local/fuel-center/-/X","Costco":"https://www.costco.com/warehouse-locations-X.html#:~:text=Gas%20Station","Meijer":"https://www.meijer.com/shopping/store-locator/X.html"};
for (const [chain,url] of Object.entries(chains)){
const chainId=chain.toLowerCase().replace(/[^a-z]/g,'');
chains[chain]=L.layerGroup().addTo(map);