NanmiCoder/MediaCrawler · error · Exception

fetch login image url failed, response message:{resp.text}

Error message

fetch login image url failed, response message:{resp.text}

What it means

Error "fetch login image url failed, response message:{resp.text}" thrown in NanmiCoder/MediaCrawler.

Source

Thrown at tools/crawler_util.py:58

from .httpx_util import make_async_client


async def find_login_qrcode(page: Page, selector: str) -> str:
    """find login qrcode image from target selector"""
    try:
        elements = await page.wait_for_selector(
            selector=selector,
        )
        login_qrcode_img = str(await elements.get_property("src"))  # type: ignore
        if "http://" in login_qrcode_img or "https://" in login_qrcode_img:
            async with make_async_client(follow_redirects=True) as client:
                utils.logger.info(f"[find_login_qrcode] get qrcode by url:{login_qrcode_img}")
                resp = await client.get(login_qrcode_img, headers={"User-Agent": get_user_agent()})
                if resp.status_code == 200:
                    image_data = resp.content
                    base64_image = base64.b64encode(image_data).decode('utf-8')
                    return base64_image
                raise Exception(f"fetch login image url failed, response message:{resp.text}")
        return login_qrcode_img

    except Exception as e:
        print(e)
        return ""


async def find_qrcode_img_from_canvas(page: Page, canvas_selector: str) -> str:
    """
    find qrcode image from canvas element
    Args:
        page:
        canvas_selector:

    Returns:

    """

View on GitHub (pinned to d6f7c5bb90)

Solutions

  1. Retry fetching the QR code image; transient network failures to the platform image host are common.
  2. Check that the login page selector still matches a live <img> element; the platform may have changed its login page markup.
  3. Verify outbound network access to the image URL (no proxy or firewall blocking it) and that the URL returned in the message is reachable with a normal GET.
  4. If the image host requires specific headers or cookies, fetch it through the same browser page/session instead of a bare HTTP client.

When it happens

Trigger: Thrown at tools/crawler_util.py:58 when the library encounters an invalid state.

Common situations: The login QR code image URL was found on the page but the HTTP fetch of the image returned a non-200 status. Causes: expired or one-time QR URL, missing referer/cookie headers required by the platform CDN, or network/proxy failure. Defensive fix: send the platform's expected headers (Referer, cookies) when fetching, and treat non-200 responses as a retryable error instead of returning an empty string upstream.


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