fish2018/pansou · error

搜索请求失败,状态码

Error message

搜索请求失败,状态码: %d

What it means

doSearch sends the search request to the u3c3 site and requires HTTP 200. Any other status (403 anti-bot, 429 rate limit, 5xx, redirects to CAPTCHA pages) results in this error. It is a guard ensuring the response body is only parsed for a successful search page.

Solutions

  1. Log resp.StatusCode and retry after a delay for 429/5xx
  2. Add browser-like headers (User-Agent, Referer, cookies) to pass anti-bot checks
  3. Try another mirror domain
  4. Route through a proxy/residential IP if the IP is blocked
  5. Check the site manually in a browser to see what the status corresponds to

Example fix

// before
if resp.StatusCode != 200 {
    return nil, fmt.Errorf("搜索请求失败,状态码: %d", resp.StatusCode)
}
// after
if resp.StatusCode == 429 {
    time.Sleep(retryAfter)
    return p.doSearch(query) // retry
}
if resp.StatusCode != 200 {
    return nil, fmt.Errorf("搜索请求失败,状态码: %d", resp.StatusCode)
}
Defensive patterns

Strategy: retry

Try / catch

results, err := u3c3Plugin.SearchWithResult(ctx, query)
var httpErr *HTTPStatusError
if errors.As(err, &httpErr) && (httpErr.Code == 429 || httpErr.Code >= 500) {
    time.Sleep(backoff)
    results, err = u3c3Plugin.SearchWithResult(ctx, query)
}

Prevention

When it happens

Trigger: SearchWithResult or TestU3c3LiveSearch reaching doSearch when the server responds with a non-200 status: 403 from Cloudflare/anti-bot, 429 rate limiting, 503 during site maintenance, or 30x not followed.

Common situations: Sending too many rapid requests and being rate-limited; the mirror serving a Cloudflare challenge; the site being under maintenance; stale domain redirecting to a block page.

Related errors


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

Appendix: source

Thrown at plugin/u3c3/u3c3.go:297

		resp, lastErr = client.Do(req)
		if lastErr == nil && resp.StatusCode == 200 {
			break
		}
		if resp != nil {
			resp.Body.Close()
		}
		if i < MaxRetries-1 {
			time.Sleep(RetryDelay)
		}
	}

	if lastErr != nil {
		return nil, lastErr
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("搜索请求失败,状态码: %d", resp.StatusCode)
	}

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	return p.parseSearchResults(string(body))
}

// parseSearchResults 解析搜索结果
func (p *U3c3Plugin) parseSearchResults(html string) ([]model.SearchResult, error) {
	doc, err := goquery.NewDocumentFromReader(strings.NewReader(html))
	if err != nil {
		return nil, err
	}

	var results []model.SearchResult

View on GitHub (pinned to beaa561337)