fish2018/pansou · error

[ ] 搜索请求返回状态码

Error message

[%s] 搜索请求返回状态码: %d

What it means

searchAtBase rejects any labi mirror response whose HTTP status is not 200. The fetch succeeded at transport level after retries, but the server answered with 403/404/5xx etc., so the plugin refuses to parse the body and fails this mirror.

Solutions

  1. Check the numeric status in the error message: 403/429 → anti-bot/rate limit, 404 → wrong URL, 5xx → upstream outage
  2. For anti-bot: improve headers (the code already sets browser-like UA/Accept/Referer), add cookies, or use a residential proxy
  3. For 404: update the search URL pattern to the site's current structure
  4. Let the caller fall back to the next mirror instead of surfacing this error directly
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "搜索请求返回状态码") {
        // parse the status from the message or track it upstream;
        // 403/429 → back off or proxy, 404 → fix path, 5xx → retry later
        return tryNextMirror(kw)
    }
    return err
}

Prevention

When it happens

Trigger: doRequestWithRetry returns a response with resp.StatusCode != 200 for the mirror's search URL — typically 403 from anti-bot WAF, 404 after a path change, or 5xx during site trouble.

Common situations: Cloudflare/WAF blocking the server IP (403), stale search path after a site redesign (404), rate limiting (429) under heavy scraping, mirror under maintenance (503).

Related errors


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

Appendix: source

Thrown at plugin/labi/labi.go:204

	// 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", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
	req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
	req.Header.Set("Connection", "keep-alive")
	req.Header.Set("Upgrade-Insecure-Requests", "1")
	req.Header.Set("Cache-Control", "max-age=0")
	req.Header.Set("Referer", strings.TrimRight(baseURL, "/")+"/")

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

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("[%s] 搜索请求返回状态码: %d", p.Name(), resp.StatusCode)
	}

	// 3. 解析搜索结果页面
	doc, err := goquery.NewDocumentFromReader(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("[%s] 解析搜索页面失败: %w", p.Name(), err)
	}

	// 4. 提取搜索结果
	var results []model.SearchResult

	doc.Find(".module-search-item").Each(func(i int, s *goquery.Selection) {
		result := p.parseSearchItem(s, keyword)
		if result.UniqueID != "" {
			results = append(results, result)
		}
	})

View on GitHub (pinned to beaa561337)