← back to Flock Fix Viewer
astek-vv.py
38 lines
import urllib.request, json, re, html
vv = []
for pg in range(1, 40):
try:
req = urllib.request.Request(f'https://www.astek.com/products.json?limit=250&page={pg}',
headers={'User-Agent': 'Mozilla/5.0'})
prods = json.load(urllib.request.urlopen(req, timeout=25)).get('products', [])
if not prods:
break
for p in prods:
m = re.match(r'\s*(VV\d+)\b', p['title'])
if m:
vv.append((m.group(1), p))
except Exception as e:
break
def txt(p):
b = html.unescape(re.sub(r'<[^>]+>', ' ', p.get('body_html', '')))
return re.sub(r'\s+', ' ', b)
def spec(p, kw):
m = re.search(kw + r'[^0-9]*([\d.]+)\s*(?:inch|in|")', txt(p), re.I)
return m.group(1) if m else '?'
def soldby(p):
m = re.search(r'Sold By ([A-Za-z ]+?)(?:Motif|Substrate|Vertical|$)', txt(p), re.I)
return m.group(1).strip() if m else '?'
print('Astek VV-flocked products:', len(vv))
for code, p in sorted(vv, key=lambda x: x[0]):
title = p['title'][:38]
pw = spec(p, 'Printed width')
sb = soldby(p)
nc = len(p['variants'])
pr = p['variants'][0]['price']
skus = ','.join((v.get('sku') or '') for v in p['variants'][:2])
print(f' {code} | {title:38} | W={pw}" | soldBy={sb:14} | colorways={nc} | ${pr} | sku={skus[:30]}')