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

@ -117,7 +117,8 @@ async def scrape_url(client: httpx.AsyncClient, url: str, cache: Cache | None =
"extractor_used": extracted.get("extractor_used"),
"thin": extracted.get("thin", False),
}
if cache and result["content"] and not result["thin"]:
blocked = result["status"] is not None and result["status"] >= 400
if cache and result["content"] and not result["thin"] and not blocked:
await cache.set_json(cache_key, result, config.EXTRACT_CACHE_TTL)
return {**result, "trace": trace.as_dict()}
@ -155,8 +156,15 @@ async def search_contents(
"title": page.get("title") or meta["title"],
"metadata": page.get("metadata", {}),
"final_url": page.get("final_url"),
"status": page.get("status"),
"thin": page.get("thin", False),
}
)
# Blocked (4xx/5xx) or empty/thin pages are quality failures even
# though the render itself "succeeded" — surface them, don't hide them.
status = page.get("status")
if (status and status >= 400) or page.get("thin") or not page["content"]:
failed.append(meta["url"])
out.append(entry)
if failed:
trace.degraded.append("contents")