fish2018/pansou · error

[ ] HTTP错误

Error message

[%s] HTTP错误: %d

What it means

The yuhuage upstream returned an HTTP status other than 200 (and other than the already-handled 429). searchImpl rejects any non-200 response because it expects an HTML search page to parse. The actual code is included in the message.

Solutions

  1. Check the status code in the message: 403 means bot detection (update headers/cookies), 5xx means wait and retry.
  2. Curl the search URL with the plugin's headers to reproduce and inspect the response.
  3. Verify BaseURL (https://www.iyuhuage.fun) and SearchPath are still correct — update if the site moved.
  4. Add retry/backoff for transient 5xx, similar to the existing 429 handling.

Example fix

// before
if resp.StatusCode != 200 {
    return nil, fmt.Errorf("[%s] HTTP错误: %d", p.Name(), resp.StatusCode)
}
// after
if resp.StatusCode >= 500 {
    return nil, retryableStatusError{code: resp.StatusCode}
}
if resp.StatusCode != 200 {
    return nil, fmt.Errorf("[%s] HTTP错误: %d", p.Name(), resp.StatusCode)
}
Defensive patterns

Strategy: fallback

Validate before calling

resp, err := http.Get("https://www.iyuhuage.fun/search/test-1-time.html")
if err == nil {
    defer resp.Body.Close()
    if resp.StatusCode != 200 {
        // upstream unhealthy, use alternative plugin
    }
}

Try / catch

results, err := plugin.Search(keyword, ext)
if err != nil {
    var httpErr struct{ code int }
    if strings.Contains(err.Error(), "HTTP错误: 403") {
        log.Printf("yuhuage bot-blocked, using fallback: %v", err)
        return fallbackResults, nil
    }
    if strings.Contains(err.Error(), "HTTP错误: 5") {
        time.Sleep(backoff)
        results, err = plugin.Search(keyword, ext)
    }
}

Prevention

When it happens

Trigger: resp.StatusCode is not 200 and not 429 — commonly 403 (bot/WAF block), 5xx (server error), 404 (site restructured its search path), or 30x redirect responses.

Common situations: The site enabled Cloudflare bot detection returning 403; temporary upstream outages (502/503); the site changed BaseURL or search path so requests hit a 404; TLS/proxy middleware injecting error pages.

Related errors


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

Appendix: source

Thrown at plugin/yuhuage/yuhuage.go:113

	
	// 发送HTTP请求
	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 == 429 {
		atomic.StoreInt32(&p.rateLimited, 1)
		go func() {
			time.Sleep(60 * time.Second)
			atomic.StoreInt32(&p.rateLimited, 0)
		}()
		return nil, fmt.Errorf("[%s] 请求被限流", p.Name())
	}
	
	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("[%s] HTTP错误: %d", p.Name(), resp.StatusCode)
	}
	
	// 读取响应
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("[%s] 读取响应失败: %w", p.Name(), err)
	}
	
	// 解析搜索结果
	results, err := p.parseSearchResults(string(body))
	if err != nil {
		return nil, err
	}

	if p.debugMode {
		log.Printf("[YUHUAGE] 搜索完成,获得 %d 个结果", len(results))
	}

View on GitHub (pinned to beaa561337)