fish2018/pansou · error
API返回非200状态码
Error message
API返回非200状态码: %d
What it means
pan666's fetchPage returns this when the server responds with a status code other than 200 on the final retry attempt. Earlier non-200 responses trigger a 500ms sleep and retry; once retries are exhausted the offending status code is reported. Note the response body — which may contain the API's error details — is discarded.
Solutions
- Read a snippet of the response body before giving up — it usually names the block reason
- Slow down request rate / add jitter if 429
- Stop rotating X-Forwarded-For if the API bans on inconsistent forwarded IPs
- Verify the BaseURL endpoint is still valid (404 case) and update it
Example fix
// before
if resp.StatusCode != http.StatusOK {
if i == p.retries { return nil, false, fmt.Errorf("API返回非200状态码: %d", resp.StatusCode) }
// after
if resp.StatusCode != http.StatusOK {
b, _ := io.ReadAll(io.LimitReader(resp.Body, 256))
if i == p.retries { return nil, false, fmt.Errorf("API返回非200状态码: %d body=%.256s", resp.StatusCode, b) } Defensive patterns
Strategy: retry
Try / catch
if err != nil {
if strings.Contains(err.Error(), "429") {
select {
case <-time.After(rateLimitCooldown):
case <-ctx.Done():
return ctx.Err()
}
return retry()
}
return err
} Prevention
- Back off significantly on 429 instead of fixed 500ms retries
- Log response bodies of non-200 replies to learn block reasons
- Keep request rate well below known API limits
- Detect and stop using headers that trigger WAF bans (e.g. random X-Forwarded-For)
When it happens
Trigger: client.Do succeeds and resp.StatusCode != http.StatusOK on all attempts: 403 (WAF/ban), 429 (rate limit), 500/502/503 (upstream fault), or 404 after an endpoint change.
Common situations: Rate limiting due to rapid searches; IP banned because of the randomized X-Forwarded-For/UA headers; pan666 API endpoint moved returning 404; origin server outage behind a gateway.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/dfc9cd1816e7ac90.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/pan666/pan666.go:228
continue
}
defer resp.Body.Close()
// 读取响应体
responseBody, err = io.ReadAll(resp.Body)
if err != nil {
if i == p.retries {
return nil, false, fmt.Errorf("读取响应失败: %w", err)
}
time.Sleep(500 * time.Millisecond)
continue
}
// 状态码检查
if resp.StatusCode != http.StatusOK {
if i == p.retries {
return nil, false, fmt.Errorf("API返回非200状态码: %d", resp.StatusCode)
}
time.Sleep(500 * time.Millisecond)
continue
}
// 请求成功,跳出重试循环
break
}
// 解析响应
var apiResp Pan666Response
if err := json.Unmarshal(responseBody, &apiResp); err != nil {
return nil, false, fmt.Errorf("解析响应失败: %w", err)
}
// 处理结果
results := make([]model.SearchResult, 0, len(apiResp.Data))
postMap := make(map[string]Pan666Post)View on GitHub (pinned to beaa561337)