package fetch import ( "bytes" "net/http" "strings" ) // Verdict says what a response means for the watcher. type Verdict int const ( // OK is a page the plugin can parse. OK Verdict = iota // NotFound (404, 410) means the item is not available, never an error. NotFound // Challenge is a bot check that a real browser may clear. Challenge // Blocked is a refusal without a recognisable challenge, such as a plain // 403 or 429. The host is backed off and retried later. Blocked // HTTPError is any other non-2xx status. HTTPError ) func (v Verdict) String() string { switch v { case OK: return "ok" case NotFound: return "not-found" case Challenge: return "challenge" case Blocked: return "blocked" case HTTPError: return "http-error" default: return "unknown" } } type marker struct { name string needle string } // strongMarkers only appear on bot check pages, so they count whatever the // status. Amazon answers its captcha with a 200, for example. var strongMarkers = []marker{ {"cloudflare", "window._cf_chl_opt"}, {"amazon-captcha", `action="/errors/validateCaptcha"`}, {"datadome", "geo.captcha-delivery.com"}, {"perimeterx", `id="px-captcha"`}, } // weakMarkers also show up on normal pages (Cloudflare injects its // challenge-platform script, shops embed Turnstile in forms), so they only // count on a refusal status. var weakMarkers = []marker{ {"cloudflare", "