NanmiCoder/MediaCrawler · error · IpGetError

{error_msg} (code: {error_code})

Error message

{error_msg} (code: {error_code})

What it means

Raised by WanDouHttpProxy.get_proxies() when the Wandou (豌豆代理) API response JSON has a non-success code. The message embeds the provider's msg and code, with friendly overrides for 10001 (general error) and 10048 (no available package). This is Wandou's application-level error: HTTP succeeded but the account/order state is wrong.

Source

Thrown at proxy/providers/wandou_http_proxy.py:106

                        expired_time_ts=utils.get_unix_time_from_time_str(
                            ip_item.get("expire_time")
                        ),
                    )
                    ip_key = f"WANDOUHTTP_{ip_info_model.ip}_{ip_info_model.port}"
                    ip_value = ip_info_model.model_dump_json()
                    ip_infos.append(ip_info_model)
                    self.ip_cache.set_ip(
                        ip_key, ip_value, ex=ip_info_model.expired_time_ts - current_ts
                    )
            else:
                error_msg = res_dict.get("msg", "unknown error")
                # Handle specific error codes
                error_code = res_dict.get("code")
                if error_code == 10001:
                    error_msg = "General error, check msg content for specific error information"
                elif error_code == 10048:
                    error_msg = "No available package"
                raise IpGetError(f"{error_msg} (code: {error_code})")
        return ip_cache_list + ip_infos


def new_wandou_http_proxy() -> WanDouHttpProxy:
    """
    Construct WanDou HTTP instance
    Supports two environment variable naming formats:
    1. Uppercase format: WANDOU_APP_KEY
    2. Lowercase format: wandou_app_key
    Prioritize uppercase format, use lowercase format if not exists
    Returns:

    """
    # Support both uppercase and lowercase environment variable formats, prioritize uppercase
    app_key = os.getenv("WANDOU_APP_KEY") or os.getenv("wandou_app_key", "your_wandou_http_app_key")

    return WanDouHttpProxy(app_key=app_key)

View on GitHub (pinned to d6f7c5bb90)

Solutions

  1. For code 10048: log in to the Wandou console and purchase/renew an extraction package
  2. Verify the WANDOU_APP_KEY environment variable matches the key shown in the Wandou console (uppercase WANDOU_APP_KEY takes priority over lowercase wandou_app_key)
  3. For 10001: read the embedded msg — usually invalid key or param — and correct the credential
  4. Reduce concurrent get_proxies() callers to stay within the package's concurrency allowance
  5. Catch IpGetError and retry after a short delay once the package window resets

Example fix

// before
raise IpGetError(f"{error_msg} (code: {error_code})")

// after — caller side
try:
    proxies = await wandou.get_proxies(num=n)
except IpGetError as e:
    if "code: 10048" in str(e):
        utils.logger.warning("wandou package unavailable, falling back to cached ips")
        proxies = await pool.serve_from_cache()
    else:
        raise
Defensive patterns

Strategy: try-catch

Try / catch

try:
    infos = await wandou.get_proxies(num=n)
except IpGetError as e:
    if "(code: 10048)" in str(e):
        utils.logger.warning("wandou package exhausted; continuing with cache")
        infos = []
    elif "(code: 10001)" in str(e):
        raise RuntimeError(f"wandou credentials invalid: {e}") from e
    else:
        raise

Prevention

When it happens

Trigger: Calling get_proxies() with an invalid/expired WANDOU_APP_KEY, an account whose proxy package is exhausted or expired (10048), wrong ApiKey vs AppKey mix-up, or requesting more concurrent IPs than the package allows.

Common situations: Free trial package used up; WANDOU_APP_KEY env var typo'd or set to the wrong key type; package expired at midnight; running more crawler workers than the package's concurrency limit.

Related errors


AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15). Data as JSON: /api/errors/eeeca2a76512068e. Report an issue: GitHub.