{"record":{"id":"9131720297ccad65","repo":"fish2018/pansou","slug":"error-913172","errorCode":null,"errorMessage":"磁力链接为空","messagePattern":"磁力链接为空","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugin/wuji/wuji.go","lineNumber":346,"sourceCode":"\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 {\n\t// 移除【】之间的广告内容\n\ttitle = regexp.MustCompile(`【[^】]*】`).ReplaceAllString(title, \"\")\n\t// 移除数字+【】格式的广告\n\ttitle = regexp.MustCompile(`^\\d+【[^】]*】`).ReplaceAllString(title, \"\")\n\t// 移除[]之间的内容（如有需要）","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/wuji/wuji.go#L328-L364","documentation":"The magnet input element exists but its \"value\" attribute is missing or an empty string, so fetchMagnetLink throws this error. The page structure is right but the plugin got no usable magnet payload — typically the server rendered the form without filling in the value for this resource.","triggerScenarios":"doc.Find(\"input#input-magnet\") matched an element, but magnetInput.Attr(\"value\") returns exists=false or magnetLink==\"\": the input is a placeholder/search box rather than the populated magnet field, or the resource genuinely has no magnet yet and the template renders an empty value.","commonSituations":"Site template change moving the actual magnet to a different attribute or element while leaving a decoy input with the same id; resources whose magnet is generated asynchronously and left empty in initial HTML; scraping a page variant (mobile/AMP) with an unfilled input.","solutions":["Inspect the actual page HTML for the resource; locate where the magnet string now lives (data attribute, hidden input, JS variable).","Log which detailURL produced the empty magnet so pattern issues (specific resources) can be separated from template changes.","Add a fallback selector set (e.g. input[name=hash], a[data-magnet]) before failing.","Skip and continue enrichment for other results instead of treating one empty magnet as fatal (enrichWithMagnetLinks is per-result)."],"exampleFix":"// before\nmagnetLink, exists := magnetInput.Attr(\"value\")\nif !exists || magnetLink == \"\" {\n    return \"\", fmt.Errorf(\"磁力链接为空\")\n}\n// after\nmagnetLink, exists := magnetInput.Attr(\"value\")\nif !exists || magnetLink == \"\" {\n    magnetLink, exists = magnetInput.Attr(\"data-magnet\")\n}\nif !exists || magnetLink == \"\" {\n    return \"\", fmt.Errorf(\"磁力链接为空 (%s)\", detailURL)\n}","handlingStrategy":"fallback","validationCode":"v, ok := magnetInput.Attr(\"value\")\nif !ok || v == \"\" {\n    // try alternates before failing\n    v, ok = magnetInput.Attr(\"data-magnet\")\n}","typeGuard":null,"tryCatchPattern":"magnet, err := p.fetchMagnetLink(client, detailURL)\nif err != nil && strings.Contains(err.Error(), \"磁力链接为空\") {\n    return \"\" // resource simply has no magnet; not fatal\n}","preventionTips":["Check alternate attributes/elements holding the magnet value","Log the affected detailURL to separate per-resource gaps from template changes","Treat empty magnets as per-result degradation, not global failure"],"tags":["html","scraping","dom","empty-value"],"backgroundTag":"empty-required-field","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"}