{"record":{"id":"bb83774bc981bcd3","repo":"fish2018/pansou","slug":"html-w-bb8377","errorCode":null,"errorMessage":"解析搜索结果HTML失败: %w","messagePattern":"解析搜索结果HTML失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/xb6v/xb6v.go","lineNumber":303,"sourceCode":"\tresp2, err := p.doRequest(client, \"GET\", resultURL, \"\", p.currentBase)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"获取搜索结果失败: %w\", err)\n\t}\n\tdefer resp2.Body.Close()\n\n\tif resp2.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"搜索结果响应状态码异常: %d\", resp2.StatusCode)\n\t}\n\n\t// 解析搜索结果页面\n\treader, err := p.getResponseReader(resp2)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdoc, err := goquery.NewDocumentFromReader(reader)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"解析搜索结果HTML失败: %w\", err)\n\t}\n\n\t// 提取搜索结果（详情页链接和日期）\n\tdetailPages := p.extractDetailURLs(doc)\n\n\tif p.debugMode {\n\t\tlog.Printf(\"[Xb6v] 找到 %d 个详情页链接\", len(detailPages))\n\t}\n\n\tif len(detailPages) == 0 {\n\t\treturn nil, fmt.Errorf(\"未找到搜索结果\")\n\t}\n\n\t// 限制结果数量\n\tif len(detailPages) > MaxResults {\n\t\tdetailPages = detailPages[:MaxResults]\n\t}\n","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/xb6v/xb6v.go#L285-L321","documentation":"xb6v's searchImpl parses the search-results page HTML with goquery.NewDocumentFromReader. If goquery (via the underlying charset/HTML reader) fails to build a document, this error wraps the cause. In practice goquery rarely errors, so this usually reflects a reader-level failure such as a charset decoder error on malformed bytes.","triggerScenarios":"goquery.NewDocumentFromReader(reader) returns an error while consuming the (possibly gzip-decompressed, charset-converted) response body of the results page — typically invalid byte sequences for the detected charset or a decompression error surfaced during the first read.","commonSituations":"Mirror serves content in a charset the transformer doesn't support or emits broken multi-byte sequences; the gzip stream is corrupt so the decoder errors mid-parse; a proxy injects content breaking the encoding.","solutions":["Retry — corrupted transfer/encoding is usually transient.","Inspect Content-Encoding and charset headers in debug logs; confirm the body decodes cleanly (curl --compressed | file -).","Verify the mirror is serving intact pages; switch mirrors if the HTML is consistently malformed."," Harden getResponseReader to validate the gzip stream and fall back to raw bytes before parsing."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := pluginSearch(keyword)\nif err != nil && strings.Contains(err.Error(), \"解析搜索结果HTML失败\") {\n\t// corrupt transfer/encoding — retry once; then switch mirror\n}","preventionTips":["Avoid proxies that alter or truncate response bodies.","Verify mirror serves valid gzip and correct charset.","Treat repeated parse failures as a signal to change mirrors."],"tags":["html-parsing","goquery","charset","gzip"],"backgroundTag":"invalid-json-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"}