{"record":{"id":"271335841aa751a4","repo":"fish2018/pansou","slug":"s-cloudflare-271335","errorCode":null,"errorMessage":"站点 %s 已迁移并启用 Cloudflare 浏览器验证，当前服务端请求无法通过","messagePattern":"站点 (.+?) 已迁移并启用 Cloudflare 浏览器验证，当前服务端请求无法通过","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/xdpan/xdpan.go","lineNumber":450,"sourceCode":"\t\t\t// 指数退避重试\n\t\t\tbackoff := time.Duration(1<<uint(i-1)) * 500 * time.Millisecond\n\t\t\tif DebugLog {\n\t\t\t\tfmt.Printf(\"[xdpan] 重试第%d次，等待%v\\n\", i, backoff)\n\t\t\t}\n\t\t\ttime.Sleep(backoff)\n\t\t}\n\n\t\t// 克隆请求避免并发问题\n\t\treqClone := req.Clone(req.Context())\n\n\t\tresp, err := client.Do(reqClone)\n\t\tif err != nil {\n\t\t\tlastErr = err\n\t\t\tcontinue\n\t\t}\n\t\tif strings.EqualFold(resp.Header.Get(\"cf-mitigated\"), \"challenge\") {\n\t\t\tresp.Body.Close()\n\t\t\treturn nil, fmt.Errorf(\"站点 %s 已迁移并启用 Cloudflare 浏览器验证，当前服务端请求无法通过\", p.baseURL)\n\t\t}\n\t\tif resp.StatusCode == http.StatusOK {\n\t\t\treturn resp, nil\n\t\t}\n\t\tlastErr = fmt.Errorf(\"HTTP %d\", resp.StatusCode)\n\t\tresp.Body.Close()\n\t}\n\tif lastErr == nil {\n\t\tlastErr = fmt.Errorf(\"未知请求错误\")\n\t}\n\treturn nil, fmt.Errorf(\"重试 %d 次后仍然失败: %w\", MaxRetries, lastErr)\n}\n\n// setRequestHeaders 设置请求头\nfunc (p *XdpanPlugin) setRequestHeaders(req *http.Request) {\n\treq.Header.Set(\"User-Agent\", UserAgent)\n\treq.Header.Set(\"Referer\", strings.TrimRight(p.baseURL, \"/\")+\"/?p=baidu\")\n\treq.Header.Set(\"Accept\", \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\")","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/xdpan/xdpan.go#L432-L468","documentation":"doRequestWithRetry inspects the cf-mitigated response header; when its value is 'challenge', Cloudflare has explicitly signaled that the request was intercepted by a browser-verification challenge. The plugin closes the body and fails fast with this site-specific message instead of wasting retries.","triggerScenarios":"Any request through doRequestWithRetry (search or detail pages) whose response carries header cf-mitigated: challenge, regardless of status code.","commonSituations":"Site enabled Cloudflare bot management/under-attack mode; requests originate from datacenter IPs; User-Agent or TLS fingerprint identified as automated.","solutions":["Accept that the site cannot be scraped server-side and surface the message to users","Switch to a headless browser that executes the challenge","Use residential proxies or a different network egress","Monitor the site and disable the plugin until protection is lifted"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if strings.EqualFold(resp.Header.Get(\"cf-mitigated\"), \"challenge\") {\n    return errCloudflareChallenge\n}","typeGuard":null,"tryCatchPattern":"resp, err := doRequestWithRetry(req, client)\nif err != nil && strings.Contains(err.Error(), \"Cloudflare\") {\n    return nil, err // fail fast, do not retry\n}","preventionTips":["Check cf-mitigated header on every response","Stop retrying once a challenge is signaled","Consider headless-browser or proxy fallback","Track which sites have enabled bot protection"],"tags":["cloudflare","anti-bot","network"],"backgroundTag":"cloudflare-challenge-blocked","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}