{"record":{"id":"89bd7512fb45f435","repo":"fish2018/pansou","slug":"d-89bd75","errorCode":null,"errorMessage":"首页请求返回状态码: %d","messagePattern":"首页请求返回状态码: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/qupanshe/qupanshe.go","lineNumber":174,"sourceCode":"\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"GET请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// 调试：显示从首页获取的cookies\n\tif DebugLog && client.Jar != nil {\n\t\tif u, _ := url.Parse(BaseURL); u != nil {\n\t\t\tcookies := client.Jar.Cookies(u)\n\t\t\tfmt.Printf(\"[qupanshe] 从首页获取到 %d 个cookies:\\n\", len(cookies))\n\t\t\tfor i, cookie := range cookies {\n\t\t\t\tfmt.Printf(\"  Cookie[%d]: %s=%s\\n\", i, cookie.Name, cookie.Value)\n\t\t\t}\n\t\t}\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"首页请求返回状态码: %d\", resp.StatusCode)\n\t}\n\n\t// 处理可能的gzip压缩\n\tvar reader io.Reader = resp.Body\n\tif resp.Header.Get(\"Content-Encoding\") == \"gzip\" {\n\t\tgzipReader, err := gzip.NewReader(resp.Body)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"创建gzip读取器失败: %w\", err)\n\t\t}\n\t\tdefer gzipReader.Close()\n\t\treader = gzipReader\n\t}\n\n\t// 解析HTML\n\tdoc, err := goquery.NewDocumentFromReader(reader)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"解析HTML失败: %w\", err)\n\t}","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/qupanshe/qupanshe.go#L156-L192","documentation":"getFormhash returns this error when the homepage responds with a non-200 HTTP status. The library treats any non-OK status as fatal for formhash extraction since the HTML will not contain the expected form.","triggerScenarios":"client.Do succeeds but resp.StatusCode != 200 — e.g., 403 (bot blocking), 429 (rate limited), 5xx (server error), 30x handled oddly, or a challenge page.","commonSituations":"Site WAF/Cloudflare blocking the default User-Agent, IP rate limiting after frequent searches, temporary server outage, or being redirected to a login/captcha page.","solutions":["Log resp.StatusCode and set a browser-like User-Agent in setRequestHeaders","Back off and retry later if rate-limited (429)","Check the response body for Cloudflare/captcha challenges and consider cookie warming","Verify the site is healthy (check in a browser)","Follow redirects properly (ensure client.CheckRedirect is default)"],"exampleFix":"// before\nreq.Header.Set(\"User-Agent\", \"go-http-client\")\n// after\nreq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120 Safari/537.36\")","handlingStrategy":"fallback","validationCode":"resp, err := http.Get(BaseURL)\nif err == nil && resp.StatusCode != 200 {\n    // site is returning errors/blocked; skip search or alert\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"首页请求返回状态码\") {\n    var statusErr interface{ Error() string }\n    _ = statusErr\n    // inspect status code in message: back off on 429, alert on 5xx\n}","preventionTips":["Set a browser-like User-Agent to avoid bot blocking","Throttle request rate to avoid 429s","Detect and handle challenge pages (Cloudflare etc.)","Alert on persistent 5xx — site outage"],"tags":["go","http-status","scraping","rate-limit"],"backgroundTag":"http-non-200-response","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"}