{"record":{"id":"db6197acd5c62b17","repo":"fish2018/pansou","slug":"s-http-d-db6197","errorCode":null,"errorMessage":"[%s] 搜索请求HTTP状态错误: %d","messagePattern":"\\[(.+?)\\] 搜索请求HTTP状态错误: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/dyyj/dyyj.go","lineNumber":270,"sourceCode":"\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\tif p.debugMode {\n\t\t\tlog.Printf(\"[DYYJ] 搜索请求失败: %v\", err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求失败: %w\", p.Name(), err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif p.debugMode {\n\t\tlog.Printf(\"[DYYJ] 搜索请求响应状态码: %d\", resp.StatusCode)\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\tif p.debugMode {\n\t\t\tlog.Printf(\"[DYYJ] 搜索请求HTTP状态错误: %d\", resp.StatusCode)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求HTTP状态错误: %d\", p.Name(), resp.StatusCode)\n\t}\n\n\t// 读取响应体用于调试\n\tbodyBytes, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\tif p.debugMode {\n\t\t\tlog.Printf(\"[DYYJ] 读取响应体失败: %v\", err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"[%s] 读取响应体失败: %w\", p.Name(), err)\n\t}\n\n\tbodyString := string(bodyBytes)\n\tif p.debugMode {\n\t\tlog.Printf(\"[DYYJ] 响应体大小: %d 字节\", len(bodyString))\n\n\t\t// 保存完整HTML到文件用于分析\n\t\tfilename := fmt.Sprintf(\"./dyyj_search_%s_%d.html\", url.QueryEscape(keyword), time.Now().Unix())\n\t\tif err := os.WriteFile(filename, bodyBytes, 0644); err == nil {","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/dyyj/dyyj.go#L252-L288","documentation":"dyyj.executeSearchHTML received a non-200 HTTP status from the search page. The plugin treats anything other than 200 as a failure and includes the status code in the error message. Common codes: 403 (bot blocked), 503 (challenge/overload), 404 (path changed), 5xx (server error).","triggerScenarios":"The server responded successfully at the transport level but with status != 200 after doRequestWithRetry (retries did not produce a 200).","commonSituations":"Anti-bot WAF returning 403 due to missing/rotated cookies or fingerprinting; site rate limiting (429); search path changed (404); temporary 5xx during site maintenance.","solutions":["Log the body on non-200 — the plugin already reads it; check for Cloudflare/challenge HTML","Add/refresh cookies and realistic headers (User-Agent already set) to pass the WAF","Back off longer on 429/503 and retry after a delay","Verify the search URL path is still valid (404 means the site changed)","Consider a headless-browser fallback if the site requires JS challenges"],"exampleFix":"// before\nif resp.StatusCode != 200 {\n\treturn nil, fmt.Errorf(\"[%s] 搜索请求HTTP状态错误: %d\", p.Name(), resp.StatusCode)\n}\n// after\nif resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable {\n\ttime.Sleep(retryBackoff)\n\t// retry once more before failing\n}\nif resp.StatusCode != http.StatusOK {\n\treturn nil, fmt.Errorf(\"[%s] 搜索请求HTTP状态错误: %d\", p.Name(), resp.StatusCode)\n}","handlingStrategy":"retry","validationCode":"resp, err := http.Head(probeURL)\nif err == nil && resp.StatusCode != http.StatusOK { return fmt.Errorf(\"search endpoint unhealthy: %d\", resp.StatusCode) }","typeGuard":null,"tryCatchPattern":"if resp.StatusCode != http.StatusOK {\n\tbody, _ := io.ReadAll(io.LimitReader(resp.Body, 512))\n\tif resp.StatusCode == 429 || resp.StatusCode == 503 {\n\t\t// honor Retry-After and back off\n\t}\n\treturn nil, fmt.Errorf(\"non-200 (%d): body=%q\", resp.StatusCode, body)\n}","preventionTips":["Send realistic headers and keep cookies to pass anti-bot checks","Honor Retry-After on 429/503 with real backoff","Alert on persistent 403/404 — the site path or WAF rules changed","Log a body snippet on every non-200 for diagnosis"],"tags":["http","network","scraper","anti-bot"],"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"}