NanmiCoder/MediaCrawler · error
playwright_page is required for browser-based tieba note fet
Error message
playwright_page is required for browser-based tieba note fetching
What it means
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.
Source
Thrown at media_platform/tieba/client.py:610
)
break
utils.logger.info(f"[BaiduTieBaClient.get_comments_all_sub_comments] Total retrieved {len(all_sub_comments)} sub-comments")
return all_sub_comments
async def get_notes_by_tieba_name(self, tieba_name: str, page_num: int) -> List[TiebaNote]:
"""
Get post list by Tieba name from current PC forum JSON API.
Args:
tieba_name: Tieba name
page_num: Page number
Returns:
List[TiebaNote]: Post list
"""
if not self.playwright_page:
utils.logger.error("[BaiduTieBaClient.get_notes_by_tieba_name] playwright_page is None, cannot use browser mode")
raise Exception("playwright_page is required for browser-based tieba note fetching")
page_size = 30
api_page = page_num // page_size + 1
tbs = await self._get_pc_tbs()
utils.logger.info(
f"[BaiduTieBaClient.get_notes_by_tieba_name] Accessing Tieba FRS API, "
f"tieba_name: {tieba_name}, page: {api_page}"
)
try:
api_data = await self._fetch_json_by_browser(
"/c/f/frs/page_pc",
method="POST",
data={
"kw": quote(tieba_name),
"pn": api_page,
"sort_type": -1,
"is_newfrs": 1,View on GitHub (pinned to d6f7c5bb90)
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
Defensive patterns
Strategy: type-guard
Validate before calling
if not client.playwright_page:
raise RuntimeError("tieba-name crawl needs a Playwright page; run browser bootstrap first") Type guard
def has_live_page(client) -> bool:
p = getattr(client, "playwright_page", None)
return p is not None and not p.is_closed() Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- playwright_page is required for browser-based search
- playwright_page is required for browser-based note detail fe
- playwright_page is required for browser-based comment fetchi
- playwright_page is required for browser-based creator info f
- playwright_page is required for browser-based creator notes
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/cd581867d6b6951a.
Report an issue: GitHub.