fish2018/pansou · error

[ ] 网盘第 页返回状态码

Error message

[%s] %s网盘第%d页返回状态码: %d

What it means

After a successful HTTP exchange, fetchSinglePageWithType checks the response status code and fails when it is anything other than 200. The message includes the actual status code, so the number in the error identifies the server's reaction (403 blocked, 429 rate-limited, 5xx server error, etc.).

Solutions

  1. Read the status code from the error message: 403/503 → likely anti-bot; 429 → back off; 404 → endpoint changed.
  2. For 429, reduce request rate / pages per type and retry later.
  3. For 403 with Cloudflare, the plugin's headers may need updating or the source is unusable from that IP.
  4. For 404, check whether sdso.top changed its API and update the searchURL in the plugin.
  5. Rely on other search plugins in the aggregator since one source failing is non-fatal.

Example fix

// before
for pageNo := 1; pageNo <= 10; pageNo++ { go fetch(pageNo) } // hammers the API
// after
sem := make(chan struct{}, 2) // limit concurrency
for pageNo := 1; pageNo <= 10; pageNo++ {
    sem <- struct{}{}
    go func(n int) { defer func() { <-sem }(); fetch(n) }(pageNo)
}
Defensive patterns

Strategy: fallback

Try / catch

results, err := plugin.Search(ctx, keyword)
if err != nil {
    var se struct{ Code int }
    if n, _ := fmt.Sscanf(err.Error(), "...返回状态码: %d", &se.Code); n == 1 && se.Code == 429 {
        time.Sleep(30 * time.Second) // rate-limited; back off
    }
}

Prevention

When it happens

Trigger: sdso.top's /api/sd/search endpoint returns a non-200 HTTP status for a page request, e.g. 403 (anti-bot/Cloudflare challenge), 429 (too many requests), 404 (endpoint moved), 500/502/503 (server-side problems).

Common situations: Scraping too aggressively triggers rate limiting (429); the site sits behind Cloudflare which serves a 403/503 challenge page to non-browser clients; the API path changed after a site update (404); transient upstream 5xx.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/423aba9890323912. Report an issue: GitHub.

Appendix: source

Thrown at plugin/sdso/sdso.go:257

	}

	// 4. 设置请求头
	req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
	req.Header.Set("Accept", "application/json, text/plain, */*")
	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", "https://sdso.top/")

	// 5. 发送HTTP请求(带重试机制)
	resp, err := p.doRequestWithRetry(req, client)
	if err != nil {
		return nil, fmt.Errorf("[%s] %s网盘第%d页请求失败: %w", p.Name(), fromType, pageNo, err)
	}
	defer resp.Body.Close()

	// 6. 检查状态码
	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("[%s] %s网盘第%d页返回状态码: %d", p.Name(), fromType, pageNo, resp.StatusCode)
	}

	// 7. 解析响应
	var apiResp APIResponse
	if err := json.NewDecoder(resp.Body).Decode(&apiResp); err != nil {
		return nil, fmt.Errorf("[%s] %s网盘第%d页JSON解析失败: %w", p.Name(), fromType, pageNo, err)
	}

	// 8. 检查API响应状态
	if apiResp.Code != 200 {
		return nil, fmt.Errorf("[%s] %s网盘第%d页API错误: %s", p.Name(), fromType, pageNo, apiResp.Msg)
	}

	if DebugLog {
		fmt.Printf("[%s] %s网盘第%d页获取到 %d 个原始结果\n", p.Name(), fromType, pageNo, len(apiResp.Data.List))
	}

	// 9. 转换为标准格式

View on GitHub (pinned to beaa561337)