fish2018/pansou · error

登录请求失败: HTTP

Error message

登录请求失败: HTTP %d

What it means

Login status error in panlian (plugin/panlian/panlian.go:1122): the login POST completed but returned a status other than 200, so the login response body cannot be trusted as a LoginResponse. Means credential submission was rejected at HTTP level.

Solutions

  1. Verify the panlian username/password are correct by logging in manually in a browser
  2. Check if the site now requires captcha/2FA and adapt the login flow
  3. Retry on 5xx with backoff; treat 403 as anti-bot and add browser-like headers
  4. Confirm the login endpoint URL has not changed

Example fix

// before
form := url.Values{}
form.Set("username", username)
resp, err := client.PostForm(loginURL, form)
// after
req, _ := http.NewRequest(http.MethodPost, loginURL, strings.NewReader(form.Encode()))
req.Header.Set("User-Agent", userAgent)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Referer", DefaultBaseURL)
resp, err := client.Do(req)
Defensive patterns

Strategy: try-catch

Validate before calling

if loginURL, err := url.Parse(DefaultBaseURL + "/login"); err != nil || !loginURL.IsAbs() {
    return errors.New("invalid login endpoint")
}

Try / catch

if err := doLoginFlow(); err != nil {
    var httpErr interface{ StatusCode() int }
    if strings.Contains(err.Error(), "登录请求失败: HTTP 403") {
        log.Print("login blocked (anti-bot/captcha) — verify credentials manually")
    }
    return err
}

Prevention

When it happens

Trigger: POSTing the login form when credentials trigger a non-200 response, the WAF blocks the login POST, or the server returns 5xx during login.

Common situations: 登录参数缺失被服务端拒绝;触发风控。

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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

Appendix: source

Thrown at plugin/panlian/panlian.go:1122

		return "", nil, err
	}
	p.setPanlianHeaders(req, preCookie, DefaultBaseURL+"/pages/login.php")
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")

	resp, err = client.Do(req)
	if err != nil {
		cancel()
		return "", nil, err
	}
	defer resp.Body.Close()

	respBody, err := io.ReadAll(resp.Body)
	cancel()
	if err != nil {
		return "", nil, err
	}
	if resp.StatusCode != http.StatusOK {
		return "", nil, fmt.Errorf("登录请求失败: HTTP %d", resp.StatusCode)
	}

	var loginResp LoginResponse
	if err := json.Unmarshal(respBody, &loginResp); err != nil {
		return "", nil, fmt.Errorf("解析登录响应失败: %w", err)
	}
	if !loginResp.Success {
		return "", nil, errors.New(strings.TrimSpace(loginResp.Message))
	}

	cookieString := cookiesToString(jar.Cookies(baseURL))
	if cookieString == "" {
		return "", nil, fmt.Errorf("登录成功但未获取到有效 Cookie")
	}

	return cookieString, &loginResp, nil
}

View on GitHub (pinned to beaa561337)