{"record":{"id":"c16d9e5cc4e03fb7","repo":"NanmiCoder/MediaCrawler","slug":"can-not-extract-tieba-creator-portrait-from-url","errorCode":null,"errorMessage":"Can not extract Tieba creator portrait from url: {creator_url}","messagePattern":"Can not extract Tieba creator portrait from url: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"media_platform/tieba/client.py","lineNumber":661,"sourceCode":"            utils.logger.error(f\"[BaiduTieBaClient.get_notes_by_tieba_name] Failed to get Tieba post list: {e}\")\n            raise\n\n    async def get_creator_info_by_url(self, creator_url: str) -> TiebaCreator:\n        \"\"\"\n        Get creator information by creator URL from current PC JSON API.\n        Args:\n            creator_url: Creator homepage URL\n\n        Returns:\n            TiebaCreator: Creator information\n        \"\"\"\n        if not self.playwright_page:\n            utils.logger.error(\"[BaiduTieBaClient.get_creator_info_by_url] playwright_page is None, cannot use browser mode\")\n            raise Exception(\"playwright_page is required for browser-based creator info fetching\")\n\n        portrait = self._extract_creator_portrait(creator_url)\n        if not portrait:\n            raise Exception(f\"Can not extract Tieba creator portrait from url: {creator_url}\")\n\n        utils.logger.info(\n            f\"[BaiduTieBaClient.get_creator_info_by_url] Accessing creator info API, portrait: {portrait}\"\n        )\n\n        try:\n            api_data = await self._fetch_json_by_browser(\n                \"/c/u/pc/homeSidebarRight\",\n                params={\n                    \"portrait\": portrait,\n                    \"un\": \"\",\n                    \"subapp_type\": \"pc\",\n                    \"_client_type\": \"20\",\n                },\n                use_sign=True,\n            )\n            return self._page_extractor.extract_creator_info_from_api(api_data)\n","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/tieba/client.py#L643-L679","documentation":"Raised by BaiduTieBaClient.get_creator_info_by_url (media_platform/tieba/client.py:661) when _extract_creator_portrait(creator_url) returns a falsy value. Tieba creator homepages embed a 'portrait' identifier in the URL; the API call that fetches creator info is keyed on that portrait. If the URL doesn't match the expected pattern, the extractor returns None and this exception names the offending URL.","triggerScenarios":"Passing a creator_url that is not a Tieba user-homepage URL containing a portrait segment — e.g. 'https://tieba.baidu.com/home/main?id=...' without a portrait, a plain username URL, a forum URL, or a malformed/empty string.","commonSituations":"Feeding creator URLs scraped from third-party pages or hand-copied from a browser after redirects; URL format changes on Tieba's side that break the portrait regex; mixing up creator URL with post URL in crawler config.","solutions":["Use the canonical creator homepage URL form that contains the portrait hash (check _extract_creator_portrait's expected pattern and match your URL to it)","If you only have a username, use get_notes_by_creator(user_name, ...) instead of the URL-based API","Log the failing URL and verify it opens a real Tieba user homepage in a browser"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from media_platform.tieba.client import BaiduTieBaClient\nprobe = BaiduTieBaClient.__new__(BaiduTieBaClient)\nif not probe._extract_creator_portrait(creator_url):  # if extractor is instance-level, use an initialized dummy\n    raise ValueError(f\"Not a valid creator homepage URL: {creator_url}\")","typeGuard":"def is_portrait_url(url: str) -> bool:\n    # mirror the pattern _extract_creator_portrait expects: portrait hash present in the path/query\n    return isinstance(url, str) and \"tieba.baidu.com\" in url and \"portrait\" in url","tryCatchPattern":"try:\n    creator = await client.get_creator_info_by_url(creator_url)\nexcept Exception as e:\n    if \"Can not extract\" in str(e):\n        log_bad_creator_url(creator_url)  # quarantine and continue batch\n        return None\n    raise","preventionTips":["Validate creator URLs in config at startup, quarantine malformed ones","Copy creator homepage URLs directly from the browser address bar after the profile loads","Prefer username-based APIs when only usernames are available"],"tags":["tieba","url-parsing","creator","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}