scripts/scan.py
scripts/scan.pyBrowse 56 files
312 tokens
1,308 bytes
Token encoding: o200k_base
Snapshot 24fd22b
← Back to SKILL.md
1"""Stdlib fetch helper for simple url_pattern brokers (osint-style).2 3For JS-rendered or anti-bot pages the agent should use the `web_extract` or4`browser_navigate` tools (and the `scrapling` skill for stealth/Cloudflare).5This helper only covers plain static pages and is intentionally network-light so6it can be mocked in tests.7"""8from __future__ import annotations9 10import urllib.error11import urllib.request12 13USER_AGENT = "Mozilla/5.0 (compatible; unbroker/1.0; data opt-out)"14 15 16def fetch(url: str, timeout: int = 20) -> tuple[int, str]:17 req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT})18 try:19 with urllib.request.urlopen(req, timeout=timeout) as resp: # noqa: S310 (https only by convention)20 charset = resp.headers.get_content_charset() or "utf-8"21 return getattr(resp, "status", 200), resp.read().decode(charset, errors="replace")22 except urllib.error.HTTPError as exc:23 return exc.code, ""24 except (urllib.error.URLError, TimeoutError, ValueError):25 return 0, ""26 27 28def looks_listed(html: str, match_signal: str | None) -> bool:29 """Naive confirmation heuristic for static pages: does the match signal appear?"""30 if not html or not match_signal:31 return False32 return match_signal.lower() in html.lower()33