fish2018/pansou · error
[ ] POST搜索请求失败
Error message
[%s] POST搜索请求失败: %w
What it means
searchImpl wraps any failure from postSearchRequest, which POSTs the search keyword with the formhash to obtain the search-result URL. Failure means the POST request errored, returned an unexpected status, or the result URL could not be extracted.
Solutions
- Confirm Step 1 succeeded and the formhash is fresh — always reuse the same sessionClient so cookies persist
- Enable DebugLog to inspect the POST response status and body
- Verify POST form field names still match the site's current search form
- Add retries with backoff for transient network errors or rate limiting
- Check for anti-bot/Cloudflare challenges in the response body
Defensive patterns
Strategy: retry
Try / catch
if err != nil && strings.Contains(err.Error(), "POST搜索请求失败") {
// formhash may be stale or request blocked; redo full flow (fresh formhash) once
return fullFlowWithRetry(ctx, keyword, 1)
} Prevention
- Run Steps 1-3 quickly in a single session so the formhash stays fresh
- Match the site's current POST field names and endpoint
- Respect rate limits; add delays between searches
- Detect WAF/challenge pages in response bodies
When it happens
Trigger: p.postSearchRequest(sessionClient, keyword, formhash) fails during Step 2: HTTP request creation/transport error, non-OK response, empty response body, or failure to parse the returned search URL from the response.
Common situations: Invalid or expired formhash (session cookies lost), site rate-limiting or WAF blocking the POST, network timeouts, or site form field names changed so the server rejects the request.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/cf300f91a99cb5a3.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/qupanshe/qupanshe.go:91
// Step 1: 获取首页formhash(使用session客户端)
formhash, err := p.getFormhash(sessionClient)
if err != nil {
if DebugLog {
fmt.Printf("[qupanshe] 获取formhash失败: %v\n", err)
}
return nil, fmt.Errorf("[%s] 获取formhash失败: %w", p.Name(), err)
}
if DebugLog {
fmt.Printf("[qupanshe] 获取到formhash: %s\n", formhash)
}
// Step 2: POST请求获取搜索结果URL(使用同一个session客户端)
searchURL, err := p.postSearchRequest(sessionClient, keyword, formhash)
if err != nil {
if DebugLog {
fmt.Printf("[qupanshe] POST搜索请求失败: %v\n", err)
}
return nil, fmt.Errorf("[%s] POST搜索请求失败: %w", p.Name(), err)
}
if DebugLog {
fmt.Printf("[qupanshe] 获取搜索URL成功: %s\n", searchURL)
}
// Step 3: GET请求获取搜索结果(使用同一个session客户端)
results, err := p.getSearchResults(sessionClient, searchURL, keyword)
if err != nil {
if DebugLog {
fmt.Printf("[qupanshe] 获取搜索结果失败: %v\n", err)
}
return nil, fmt.Errorf("[%s] 获取搜索结果失败: %w", p.Name(), err)
}
if DebugLog {
fmt.Printf("[qupanshe] 获取搜索结果成功: 结果数=%d\n", len(results))
}
// Step 4: 关键词过滤View on GitHub (pinned to beaa561337)