{"record":{"id":"3c3dd2a7072939ce","repo":"fish2018/pansou","slug":"s-d-3c3dd2","errorCode":null,"errorMessage":"[%s] 搜索请求返回状态码: %d","messagePattern":"\\[(.+?)\\] 搜索请求返回状态码: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/muou/muou.go","lineNumber":224,"sourceCode":"\n\t// 4. 设置完整的请求头（避免反爬虫）\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36\")\n\treq.Header.Set(\"Accept\", \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\")\n\treq.Header.Set(\"Accept-Language\", \"zh-CN,zh;q=0.9,en;q=0.8\")\n\treq.Header.Set(\"Connection\", \"keep-alive\")\n\treq.Header.Set(\"Upgrade-Insecure-Requests\", \"1\")\n\treq.Header.Set(\"Cache-Control\", \"max-age=0\")\n\treq.Header.Set(\"Referer\", strings.TrimRight(baseURL, \"/\")+\"/\")\n\n\t// 5. 发送请求（带重试机制）\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求失败: %w\", p.Name(), err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求返回状态码: %d\", p.Name(), resp.StatusCode)\n\t}\n\n\t// 6. 解析搜索结果页面\n\tdoc, err := goquery.NewDocumentFromReader(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 解析搜索页面失败: %w\", p.Name(), err)\n\t}\n\n\t// 7. 提取搜索结果\n\tvar results []model.SearchResult\n\n\tdoc.Find(\".module-search-item\").Each(func(i int, s *goquery.Selection) {\n\t\tresult := p.parseSearchItem(s, keyword)\n\t\tif result.UniqueID != \"\" {\n\t\t\tresults = append(results, result)\n\t\t}\n\t})\n","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/muou/muou.go#L206-L242","documentation":"Raised in Muou's searchAtBase when the search response completed but the HTTP status is not 200. The plugin treats any non-200 as a failed search for this base URL and returns so the caller can try another base.","triggerScenarios":"Triggered when resp.StatusCode != 200: 403 (anti-bot/WAF block), 404 (path changed), 429 (rate limited), 5xx (server error), or 301/302 not followed due to redirect policy.","commonSituations":"Anti-scraping WAF blocking datacenter IPs; site redesigned and moved the search endpoint; rate limiting after rapid sequential searches; mirror serving stale redirects.","solutions":["Log the exact status code and response headers to identify blocking vs server error","Send complete browser-like headers (User-Agent, Referer, Accept-Language) to reduce 403s","Implement/increase retry with backoff for 429 and 5xx responses","Verify the search endpoint path against the current site layout","Ensure redirects are followed (default http.Client behavior; check custom CheckRedirect)"],"exampleFix":"// before\nif resp.StatusCode != 200 {\n    return nil, fmt.Errorf(\"[%s] 搜索请求返回状态码: %d\", p.Name(), resp.StatusCode)\n}\n// after\nif resp.StatusCode != http.StatusOK {\n    if resp.StatusCode == http.StatusTooManyRequests {\n        time.Sleep(5 * time.Second)\n        return p.searchAtBase(client, baseURL, keyword) // one retry after cooldown\n    }\n    return nil, fmt.Errorf(\"[%s] 搜索请求返回状态码: %d\", p.Name(), resp.StatusCode)\n}","handlingStrategy":"retry","validationCode":"req.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...\")\nreq.Header.Set(\"Referer\", baseURL + \"/\")\n// pre-flight:\nresp, err := client.Head(baseURL)\nif err == nil && resp.StatusCode == http.StatusForbidden {\n    log.Printf(\"blocked by WAF; refresh cookies/headers before searching\")\n}","typeGuard":null,"tryCatchPattern":"if resp.StatusCode != http.StatusOK {\n    if isRetryable(resp.StatusCode) { // 429, 500, 502, 503\n        backoff(); continue\n    }\n    return nil, fmt.Errorf(\"search status %d\", resp.StatusCode)\n}","preventionTips":["Send complete realistic browser headers","Throttle request rate to avoid 429s","Retry only retryable statuses (429/5xx), fail fast on 4xx","Re-verify endpoint paths when the site redesigns"],"tags":["http","status-code","scraping","go"],"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"}