SPB Git

Repository Public

enum_misc.py 5.2 KB 123 lines python

1# =============================================================================2#                  SP BOUCHER | SOFTWARE & RESEARCH3#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project          : Fabri·Ka9# File             : scripts/enum_misc.py10# Description      : Build URL lists for list-based sources.11# Module           : scripts12# Repository       : https://git.spboucher.ai/fabri-ka13# Created          : 2026-08-1214# Last Modified    : 2026-08-1215#16# =============================================================================17# AUTHOR & PROFESSIONAL AFFILIATION18# =============================================================================19#20# Author           : Simon-Pierre Boucher21# Position         : Professor of Finance22# Institution      : Université du Québec en Outaouais (UQO)23# Department       : Département des sciences administratives24# Organization     : SP Boucher25#26# Website          : https://spboucher.ai27# Git              : https://git.spboucher.ai28#29# =============================================================================30# OFFICIAL CONTACT DIRECTORY31# =============================================================================32#33# General          : info@spboucher.ai34# Professional     : contact@spboucher.ai35# Direct           : simon@spboucher.ai36# Research         : research@spboucher.ai37# Development      : dev@spboucher.ai38# Support          : support@spboucher.ai39# Security/Admin   : admin@spboucher.ai40# Notifications    : notifications@spboucher.ai41#42# Preferred Contact: contact@spboucher.ai43#44# =============================================================================45# COPYRIGHT & INTELLECTUAL PROPERTY46# =============================================================================47#48# Copyright (c) 202649# Simon-Pierre Boucher50#51# All rights reserved where applicable.52#53# This file is governed by the applicable project license,54# copyright notices, institutional agreements and relevant law.55#56# Unless expressly authorized by the applicable license or57# rights holder, copying, redistribution, sublicensing,58# publication and commercial exploitation are not permitted.59#60# Existing third-party rights and notices remain unaffected.61#62# =============================================================================63# CONFIDENTIALITY & SECURITY64# =============================================================================65#66# Classification   : Public67# Distribution     : Public repository; use is governed by the project license68# Security Contact : admin@spboucher.ai69#70# Access to this source does not independently grant permission71# to redistribute or disclose confidential materials.72#73# Do not embed credentials, private keys, access tokens,74# certificates or confidential personal information.75#76# =============================================================================77# LICENSE & MAINTENANCE78# =============================================================================79#80# License          : None specified (no license file in this repository)81# Maintainer       : Simon-Pierre Boucher82# Technical Contact: dev@spboucher.ai83#84# =============================================================================85# END OF SP BOUCHER SOURCE HEADER86# =============================================================================8788"""Build URL lists for list-based sources."""89import requests, re, time, json90HDRS={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/126 Safari/537.36"}91def get(u):92    try: return requests.get(u,headers=HDRS,timeout=25).text93    except Exception as e: print("ERR",u,e); return ""9495# --- metiersdart: expand section pages -> artisan fiche links96import sys; sys.path.insert(0,'scripts')97from harvest import sitemap_urls98secs=[u for u in sitemap_urls("https://www.metiersdart.ca/sitemap.xml") if "repertoire_artisan" in u]99fiches=set()100for s in secs:101    html=get(s)102    for m in re.findall(r'href="((?:https?://www\.metiersdart\.ca)?/?repertoire_artisan\.php\?[^"]*id=\d+[^"]*)"', html):103        u=m if m.startswith("http") else "https://www.metiersdart.ca/"+m.lstrip("/")104        fiches.add(u.replace("&","&"))105    time.sleep(0.1)106print("metiersdart fiches:",len(fiches))107open("data/raw/metiersdart_fiche_urls.txt","w").write("\n".join(sorted(fiches)))108109# --- ideecadeauquebec: boutique pages from sitemap110icq=[u for u in sitemap_urls("https://www.ideecadeauquebec.com/sitemap.xml") if "/boutique/" in u]111print("icq boutiques:",len(icq))112open("data/raw/icq_urls.txt","w").write("\n".join(sorted(set(icq))))113114# --- acheterquebecois: product-for-sale posts (each = a business listing)115aq=[u for u in sitemap_urls("https://acheterquebecois.ca/sitemap.xml") if "/produits-quebecois-a-vendre/" in u]116print("acheterquebecois:",len(aq))117open("data/raw/acheterquebecois_urls.txt","w").write("\n".join(sorted(set(aq))))118119# --- distilleriesduquebec: fr pages that are distillery profiles120dd=[u for u in sitemap_urls("https://distilleriesduquebec.com/sitemap.xml") if "/fr/" in u]121print("distilleries fr pages:",len(dd))122open("data/raw/distilleries_urls.txt","w").write("\n".join(sorted(set(dd))))123
Files main
Menu

Theme