{"record":{"id":"cd581867d6b6951a","repo":"NanmiCoder/MediaCrawler","slug":"playwright-page-is-required-for-browser-based-tieb","errorCode":null,"errorMessage":"playwright_page is required for browser-based tieba note fetching","messagePattern":"playwright_page is required for browser-based tieba note fetching","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"media_platform/tieba/client.py","lineNumber":610,"sourceCode":"                    )\n                    break\n\n        utils.logger.info(f\"[BaiduTieBaClient.get_comments_all_sub_comments] Total retrieved {len(all_sub_comments)} sub-comments\")\n        return all_sub_comments\n\n    async def get_notes_by_tieba_name(self, tieba_name: str, page_num: int) -> List[TiebaNote]:\n        \"\"\"\n        Get post list by Tieba name from current PC forum JSON API.\n        Args:\n            tieba_name: Tieba name\n            page_num: Page number\n\n        Returns:\n            List[TiebaNote]: Post list\n        \"\"\"\n        if not self.playwright_page:\n            utils.logger.error(\"[BaiduTieBaClient.get_notes_by_tieba_name] playwright_page is None, cannot use browser mode\")\n            raise Exception(\"playwright_page is required for browser-based tieba note fetching\")\n\n        page_size = 30\n        api_page = page_num // page_size + 1\n        tbs = await self._get_pc_tbs()\n        utils.logger.info(\n            f\"[BaiduTieBaClient.get_notes_by_tieba_name] Accessing Tieba FRS API, \"\n            f\"tieba_name: {tieba_name}, page: {api_page}\"\n        )\n\n        try:\n            api_data = await self._fetch_json_by_browser(\n                \"/c/f/frs/page_pc\",\n                method=\"POST\",\n                data={\n                    \"kw\": quote(tieba_name),\n                    \"pn\": api_page,\n                    \"sort_type\": -1,\n                    \"is_newfrs\": 1,","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/media_platform/tieba/client.py#L592-L628","documentation":"Raised by BaiduTieBaClient.get_notes_by_tieba_name (media_platform/tieba/client.py:610) when self.playwright_page is None. The forum post list ('FRS') is fetched through the browser via _fetch_json_by_browser('/c/f/frs/page_pc', ...), and _get_pc_tbs also depends on the page session, so a browser page is mandatory. The guard fires before any network call.","triggerScenarios":"Calling get_notes_by_tieba_name(tieba_name, page_num) on a client without an attached Playwright page — typically a tieba-name crawl started before browser/login setup or after browser teardown.","commonSituations":"Crawler configured with TIEBA_CREATOR_ID_LIST/TIEBA_NAMES but browser launch failed silently earlier; running in CI/tests without Playwright installed; reusing a client across browser restarts.","solutions":["Start the Playwright browser and attach its page to the client before tieba-name crawls","Check that Playwright browsers are installed (playwright install chromium) so launch failures don't leave the client page-less","Re-create the client after any browser restart instead of reusing the old instance"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if not client.playwright_page:\n    raise RuntimeError(\"tieba-name crawl needs a Playwright page; run browser bootstrap first\")","typeGuard":"def has_live_page(client) -> bool:\n    p = getattr(client, \"playwright_page\", None)\n    return p is not None and not p.is_closed()","tryCatchPattern":null,"preventionTips":["Fail fast at startup if browser launch fails instead of continuing page-less","Run playwright install chromium in deployment images","Rebuild the client after browser restarts"],"tags":["playwright","tieba","browser-context","validation"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}