{"record":{"id":"8b946fe40396bc0e","repo":"fish2018/pansou","slug":"error-8b946f","errorCode":null,"errorMessage":"未找到磁力链接输入框","messagePattern":"未找到磁力链接输入框","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/wuji/wuji.go","lineNumber":341,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"详情页返回状态码: %d\", resp.StatusCode)\n\t}\n\t\n\t// 读取响应体内容\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"读取详情页响应失败: %w\", err)\n\t}\n\t\n\t// 解析HTML\n\tdoc, err := goquery.NewDocumentFromReader(strings.NewReader(string(body)))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"详情页HTML解析失败: %w\", err)\n\t}\n\t\n\t// 提取磁力链接\n\tmagnetInput := doc.Find(\"input#input-magnet\")\n\tif magnetInput.Length() == 0 {\n\t\treturn \"\", fmt.Errorf(\"未找到磁力链接输入框\")\n\t}\n\t\n\tmagnetLink, exists := magnetInput.Attr(\"value\")\n\tif !exists || magnetLink == \"\" {\n\t\treturn \"\", fmt.Errorf(\"磁力链接为空\")\n\t}\n\t\n\t// 存入缓存\n\tmagnetCache.Store(detailURL, magnetCacheEntry{\n\t\tMagnetLink: magnetLink,\n\t\tTimestamp:  time.Now(),\n\t})\n\t\n\treturn magnetLink, nil\n}\n\n// cleanTitle 清理标题中的广告内容\nfunc (p *WujiPlugin) cleanTitle(title string) string {","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/wuji/wuji.go#L323-L359","documentation":"After parsing the detail page, fetchMagnetLink looks for input#input-magnet via doc.Find. If no element matches, the page did not contain the expected magnet-link input, so this error is thrown. It means the DOM structure differs from what the plugin expects — the site changed, was replaced by an error/challenge page, or the URL does not actually point at a resource detail page.","triggerScenarios":"The parsed HTML has no input element with id \"input-magnet\": a 200-status anti-bot or JS-rendered challenge page, a site redesign renaming the id, a soft-error page returned with 200, or the magnet being loaded dynamically via JavaScript so it never appears in the raw HTML.","commonSituations":"The wuji site updating its template so the input id changes; Cloudflare or a JS challenge served with status 200; the magnet input being populated client-side by JS instead of server-side; hitting a generic 'not found' page that still returns 200.","solutions":["Dump and inspect the HTML body (log first N chars) when this error occurs to see what the page actually contains.","Update the selector in code to match the site's current DOM if the template changed.","Detect challenge/error pages (e.g. body contains 'Just a moment' or title mismatch) and retry or rotate UA/cookies instead of parsing them.","Check whether the magnet value is rendered by JavaScript; if so, find the JSON/API endpoint the page calls and use that instead of scraping HTML.","Fall back to searching alternative magnet selectors or link elements containing 'magnet:' prefixes in the page."],"exampleFix":"// before\nmagnetInput := doc.Find(\"input#input-magnet\")\nif magnetInput.Length() == 0 {\n    return \"\", fmt.Errorf(\"未找到磁力链接输入框\")\n}\n// after\nmagnetInput := doc.Find(\"input#input-magnet\")\nif magnetInput.Length() == 0 {\n    // fallback: scan for a raw magnet link anywhere in the page\n    var found string\n    doc.Find(\"a[href^='magnet:']\").Each(func(_ int, s *goquery.Selection) {\n        if found == \"\" {\n            found, _ = s.Attr(\"href\")\n        }\n    })\n    if found == \"\" {\n        return \"\", fmt.Errorf(\"未找到磁力链接输入框\")\n    }\n    return found, nil\n}","handlingStrategy":"fallback","validationCode":"// after parsing, verify expected structure before extracting\nif doc.Find(\"input#input-magnet\").Length() == 0 && doc.Find(\"a[href^='magnet:']\").Length() == 0 {\n    return fmt.Errorf(\"page lacks magnet element (challenge or template change?)\")\n}","typeGuard":null,"tryCatchPattern":"magnet, err := p.fetchMagnetLink(client, detailURL)\nif err != nil {\n    log.Printf(\"no magnet found on %s: %v\", detailURL, err)\n    return \"\" // keep result without magnet\n}","preventionTips":["Log page HTML samples when selectors fail to detect template changes early","Maintain fallback selectors (raw magnet: hrefs, alternate ids)","Detect anti-bot/challenge pages by content markers and back off","Prefer the site's JSON/API endpoint over HTML scraping when available"],"tags":["html","scraping","dom","selector"],"backgroundTag":"resource-not-found","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"}