SPB Git

spb/fabri-ka Public

Agrégateur de produits québécois — www.fabri-ka.com

HTML 57.9% Python 18.6% TypeScript 15.6% CSS 7.8%
705 B · 15 lines python
Raw Blame History
1import requests, re, json, time2HDRS={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/126 Safari/537.36","HX-Request":"true"}3seen=set(); stale=0; page=14while stale<3 and page<200:5    r=requests.get(f"https://alimentsduquebec.com/entreprises?page={page}",headers=HDRS,timeout=25)6    links=set(re.findall(r'href="(https://alimentsduquebec\.com/entreprises/[a-z0-9\-]+)"',r.text))7    new=links-seen8    if not new: stale+=19    else: stale=010    seen|=links11    if page%10==0: print(page,len(seen),flush=True)12    page+=1; time.sleep(0.15)13print("final pages:",page,"unique:",len(seen))14open("data/raw/adq_enterprise_urls.txt","w").write("\n".join(sorted(seen)))15