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%
971 B · 23 lines python
Raw Blame History
1import requests, re, collections2HDRS={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126 Safari/537.36"}3def fetch(u):4    try: return requests.get(u,headers=HDRS,timeout=20).text5    except: return ""6def urls_from(x): return re.findall(r"<loc>\s*(.*?)\s*</loc>", x)7def expand(root, depth=0):8    xml=fetch(root); locs=urls_from(xml)9    if "<sitemapindex" in xml and depth<2:10        out=[]11        for l in locs: out+=expand(l,depth+1)12        return out13    return locs14for name, sm, prefix in [("fromagesdici","https://www.fromagesdici.com/sitemap.xml","/fr/"),15                          ("erabledici","https://www.erabledici.ca/sitemap_index.xml","/fr/")]:16    urls=expand(sm)17    pat=collections.Counter()18    for u in urls:19        m=re.search(r"://[^/]+(/fr/[^/]+)", u)20        if m: pat[m.group(1)+"/*"]+=121    print("="*50); print(name)22    for k,v in pat.most_common(15): print(f"  {v:6d}  {k}")23