{"record":{"id":"bbadd356a079e3ca","repo":"fish2018/pansou","slug":"s-w-bbadd3","errorCode":null,"errorMessage":"[%s] 请求搜索页面失败: %w","messagePattern":"\\[(.+?)\\] 请求搜索页面失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/aikanzy/aikanzy.go","lineNumber":162,"sourceCode":"\t// 创建请求\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", searchURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 创建请求失败: %w\", p.Name(), err)\n\t}\n\t\n\t// 设置完整的请求头（避免反爬虫）\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(\"Referer\", \"https://www.aikanzy.com/\")\n\treq.Header.Set(\"Upgrade-Insecure-Requests\", \"1\")\n\treq.Header.Set(\"Cache-Control\", \"max-age=0\")\n\t\n\t// 使用带重试的请求方法发送HTTP请求\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\t\n\t// 检查状态码\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"[%s] 请求搜索页面失败，状态码: %d\", p.Name(), resp.StatusCode)\n\t}\n\t\n\t// 使用goquery解析HTML\n\tdoc, err := goquery.NewDocumentFromReader(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 解析HTML失败: %w\", p.Name(), err)\n\t}\n\t\n\t// 解析搜索结果列表\n\tarticleItems := p.parseArticleList(doc)\n\tif len(articleItems) == 0 {\n\t\treturn []model.SearchResult{}, nil","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/aikanzy/aikanzy.go#L144-L180","documentation":"Returned by doSearch in the aikanzy plugin when the retrying HTTP client (p.doRequestWithRetry) fails to send the search request at all — no response was obtained. All underlying transport errors (connection refused, DNS, timeout, TLS) are wrapped here with the plugin name prefix.","triggerScenarios":"After the request is built with browser-like headers, p.doRequestWithRetry(req, client) exhausts its attempts because client.Do returns an error each time (site unreachable, TLS handshake failure, context deadline exceeded from defaultTimeout).","commonSituations":"The aikanzy site is down or its domain has changed; corporate firewall/GFW blocks the site; the per-request context times out on slow links; TLS certificate mismatch after the site migrates hosts.","solutions":["Unwrap the error to identify the transport cause (timeout vs connection refused vs TLS).","Confirm the site's current domain is correct and reachable (curl -v).","Increase defaultTimeout if requests time out on slow connections.","Add or update a proxy configuration if the site is blocked in your network.","If TLS errors occur, verify system CA certificates are up to date."],"exampleFix":"// before\nresp, err := p.doRequestWithRetry(req, client)\nif err != nil {\n\treturn nil, fmt.Errorf(\"[%s] 请求搜索页面失败: %w\", p.Name(), err)\n}\n// after\nresp, err := p.doRequestWithRetry(req, client)\nif err != nil {\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) && netErr.Timeout() {\n\t\treturn nil, fmt.Errorf(\"[%s] search request timed out (increase defaultTimeout or use proxy): %w\", p.Name(), err)\n\t}\n\treturn nil, fmt.Errorf(\"[%s] 请求搜索页面失败: %w\", p.Name(), err)\n}","handlingStrategy":"retry","validationCode":"// preflight check before searching\nresp, err := http.Head(baseURL)\nif err != nil {\n\treturn fmt.Errorf(\"source site unreachable: %w\", err)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"resp, err := p.doRequestWithRetry(req, client)\nif err != nil {\n\tvar dnsErr *net.DNSError\n\tif errors.As(err, &dnsErr) {\n\t\t// wrong/dead domain — refresh base URL\n\t}\n\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t// timeout — raise timeout or add proxy, then retry\n\t}\n\treturn err\n}","preventionTips":["Set explicit connect/request timeouts instead of relying on defaults.","Monitor source-site reachability and update domains promptly.","Use exponential backoff with jitter between retry attempts.","Configure a proxy for networks that block the source site."],"tags":["network","http-client","timeout","go"],"backgroundTag":"http-request-failed","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"}