fish2018/pansou · error
[ ] 接口返回状态码
Error message
[%s] 接口返回状态码: %d
What it means
searchImpl returns this when the JuPansou endpoint responds with a status code other than 200. The response body is discarded, so only the numeric code is reported. It indicates the server rejected the request (rate limit, auth, moved endpoint, WAF block).
Solutions
- Read the reported status code: 403/429 usually mean anti-bot or rate limiting — reduce request frequency or improve headers/cookies.
- Ensure the search session (ensureSearchSession) ran so required cookies are present.
- curl the endpoint with the same headers to see the raw response body for clues.
- Update the plugin if the endpoint moved (404).
- Retry later for transient 5xx.
Defensive patterns
Strategy: retry
Try / catch
results, err := p.searchImpl(client, keyword)
if err != nil {
var statusErr *fmt.wrapError
if strings.Contains(err.Error(), "接口返回状态码") {
log.Printf("jupansou returned non-200, backing off before retry: %v", err)
time.Sleep(backoff)
results, err = p.searchImpl(client, keyword)
}
if err != nil { return fallbackResults }
} Prevention
- Throttle request rate to stay under upstream limits.
- Maintain realistic browser headers and a valid session before searching.
- Alert on non-200 rates to detect WAF blocks or API deprecations early.
When it happens
Trigger: doJuPansouRequestWithRetry succeeds at transport level but resp.StatusCode != http.StatusOK — e.g. 403 from anti-bot WAF, 429 rate limit, 5xx server error.
Common situations: Cloudflare/WAF challenge pages returned as 403; request rate too high causing 429; upstream API version change returning 404/410; server-side outage producing 502/503.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/0d03dddc04eac37e.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/jupansou/jupansou.go:122
if err != nil {
return nil, fmt.Errorf("[%s] 创建请求失败: %w", p.Name(), err)
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36")
req.Header.Set("Accept", "text/event-stream")
req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Referer", jupansouBaseURL+"/")
req.Header.Set("Origin", jupansouBaseURL)
req.Header.Set("X-Requested-With", "XMLHttpRequest")
resp, err := doJuPansouRequestWithRetry(req, client)
if err != nil {
return nil, fmt.Errorf("[%s] 请求失败: %w", p.Name(), err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("[%s] 接口返回状态码: %d", p.Name(), resp.StatusCode)
}
items := make([]juPansouStreamItem, 0)
scanner := bufio.NewScanner(resp.Body)
scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if !strings.HasPrefix(line, "data:") {
continue
}
payload := strings.TrimSpace(strings.TrimPrefix(line, "data:"))
if payload == "" || payload == "[DONE]" {
continue
}
var item juPansouStreamItem
if err := json.Unmarshal([]byte(payload), &item); err != nil {View on GitHub (pinned to beaa561337)