Handle bot-blocked pages honestly: fetch fallback, degradation flags, thin threshold

- renderer: plain-fetch escalation when the browser render is blocked (4xx)
  or fails — some sites 403 automated browsers but serve plain HTTP clients
- orchestrator: blocked (>=400), empty, and thin results now appear in
  failed_urls and the degraded trace list instead of passing silently;
  blocked/thin results are never cached
- extractor: thin threshold raised to 500 chars (env: MIN_TEXT_CHARS) so
  block/challenge interstitials are flagged instead of passing as content

Outcome on TechPowerUp (fingerprints Chromium AND Firefox, JS-challenges
plain clients): still blocked — accepted per PRD §9 — but results are now
flagged thin/degraded so the calling LLM knows to rely on other sources.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
User 2026-07-06 00:12:36 -07:00
parent 4f3dc39088
commit 4bcbe8daff
3 changed files with 49 additions and 2 deletions

View file

@ -5,13 +5,16 @@ is "thin" when it's shorter than MIN_TEXT_CHARS; thin/empty primary output
triggers the fallback chain, and the longest result wins.
"""
import os
import re
import trafilatura
from readability import Document
from lxml import html as lxml_html
MIN_TEXT_CHARS = 200
# Real content pages are essentially never this short; block/challenge
# interstitials ("Automated bot check in progress...") routinely are.
MIN_TEXT_CHARS = int(os.environ.get("MIN_TEXT_CHARS", "500"))
def _trafilatura_extract(html: str, url: str, favor_recall: bool) -> str: