{"record":{"id":"016d91e91a27a8b6","repo":"fish2018/pansou","slug":"location-searchid-s","errorCode":null,"errorMessage":"无法从Location中提取searchid: %s","messagePattern":"无法从Location中提取searchid: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/clxiong/clxiong.go","lineNumber":169,"sourceCode":"\t\treturn \"\", lastErr\n\t}\n\tdefer resp.Body.Close()\n\n\t// 检查重定向响应\n\tif resp.StatusCode != 302 && resp.StatusCode != 301 {\n\t\treturn \"\", fmt.Errorf(\"期望302重定向，但得到状态码: %d\", resp.StatusCode)\n\t}\n\n\t// 从Location头部提取searchid\n\tlocation := resp.Header.Get(\"Location\")\n\tif location == \"\" {\n\t\treturn \"\", fmt.Errorf(\"重定向响应中没有Location头部\")\n\t}\n\n\t// 解析searchid\n\tsearchID := p.extractSearchIDFromLocation(location)\n\tif searchID == \"\" {\n\t\treturn \"\", fmt.Errorf(\"无法从Location中提取searchid: %s\", location)\n\t}\n\n\tif p.debugMode {\n\t\tlog.Printf(\"[CLXIONG] 获取到searchid: %s\", searchID)\n\t}\n\n\treturn searchID, nil\n}\n\n// extractSearchIDFromLocation 从Location头部提取searchid\nfunc (p *ClxiongPlugin) extractSearchIDFromLocation(location string) string {\n\t// location格式: \"result/?searchid=7549\"\n\tre := regexp.MustCompile(`searchid=(\\d+)`)\n\tmatches := re.FindStringSubmatch(location)\n\tif len(matches) > 1 {\n\t\treturn matches[1]\n\t}\n\treturn \"\"","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/clxiong/clxiong.go#L151-L187","documentation":"In getSearchID, after receiving a redirect the plugin parses the Location header with extractSearchIDFromLocation. If the URL in Location does not contain a parseable searchid, this error is thrown with the offending URL. It indicates the redirect target's format no longer matches what the parser expects.","triggerScenarios":"SearchWithResult triggers a request whose 302 Location header parses to a URL lacking the searchid parameter/path segment — e.g. the upstream changed the redirect URL structure or redirected to a login/home page.","commonSituations":"Upstream site updated its search flow so the searchid moved or was renamed; redirect goes to an error/login page instead of the results page; query-string encoding changed so the regex/parse fails.","solutions":["Log the full Location URL and compare with extractSearchIDFromLocation's expected format; update the parser to the new URL shape.","Confirm the request is authenticated/has valid cookies so the redirect goes to results, not a login page.","Check if the upstream renamed the searchid parameter and update the extraction accordingly.","Add a fallback that follows the redirect and scrapes the searchid from the response body if it is no longer in the URL."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := client.SearchWithResult(ctx, keyword)\nif err != nil && strings.Contains(err.Error(), \"无法从Location中提取searchid\") {\n    // parser out of date with upstream URL shape: try alternative plugin or re-fetch\n    res, err = fallbackSearch(ctx, keyword)\n}","preventionTips":["Keep the plugin updated when the upstream site changes its URL structure","Log full Location URLs in debug mode to detect format drift early","Ensure cookies/auth are sent so redirects land on results pages, not login pages"],"tags":["http","redirect","parsing","go"],"backgroundTag":"unexpected-response-shape","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"}