Parent: ARCHITECTURE
Code: webvac/utils/network_listener.py, webvac/utils/network_debug.py · wired in core/page_scrape_flow.py
- Capture XHR/fetch/document/script/websocket traffic during each page attempt.
- Persist JSON dumps under
{scan}/network/for failure diagnosis. - Classify challenge types and CapSolver suitability.
- Ignore analytics noise (Cloudflare RUM/beacons) that previously caused false
unknown_challengealarms.
flowchart LR
Page[Patchright Page] --> L[NetworkListener.attach]
L --> Ev[request / response / failed / finished / websocket]
Ev --> Buf[in-memory entries]
Buf --> Flush[_flush_network]
Flush --> Dump[dump_network_debug]
page_url, request_url, method, resource_type, headers, post_data, status, content_type, body_preview (truncated), optional websocket messages.
Resource focus: xhr, fetch, websocket, eventsource, document, script (+ failed/4xx of other types).
| Setting | Behavior |
|---|---|
network_debug=True (default) |
Dump on failures / challenges / auth-wall paths |
network_debug_always |
Also dump successful pages |
--no-network-debug |
No attach, no dumps |
Path pattern: {scan}/network/{host}_{UTC_timestamp}.json
Payload: page_url, final_url, reason, doc_status, captured_at, summary, entries.
Ordered classifiers (first match wins):
turnstilehcaptcharecaptcha_v3recaptcha_enterpriserecaptcha_v2managed_cfakamaidatadomeperimeterx- else
unknown_challengeif generic challenge hints match
| Suitable | Not suitable |
|---|---|
| turnstile, hcaptcha, recaptcha_* | managed_cf, akamai, datadome, perimeterx, unknown_challenge |
Summary includes capsolver_can_help, capsolver_note, tagged samples.
cdn-cgi/rum
cdn-cgi/beacon
cdn-cgi/script_monitor
cloudflareinsights.com
static.cloudflareinsights.com
Bare cdn-cgi alone is not treated as a challenge hint anymore (avoids RUM false positives).
Examples emitted into summary.root_cause_hints:
challenge_or_captcha_trafficchallenge:<type>capsolver_may_help/capsolver_unlikelyrate_limited_429auth_or_forbiddenupstream_5xxno_network_events_captured
- CRAWL —
_attach_network/_flush_network - CAPTCHA — widget solving vs managed challenges
- SCAN_LAYOUT — where dumps live