NanmiCoder/MediaCrawler · error
playwright_page is required for browser-based creator info f
Error message
playwright_page is required for browser-based creator info fetching
What it means
Raised by BaiduTieBaClient.get_creator_info_by_url (media_platform/tieba/client.py:657) when self.playwright_page is None. Creator info comes from the PC JSON API fetched inside a browser session (_fetch_json_by_browser on /c/u/pc/homeSidebarRight), so the method refuses without a page. It is the browser-guard sibling of the portrait-extraction check that follows it at line 661.
Source
Thrown at media_platform/tieba/client.py:657
utils.logger.info(f"[BaiduTieBaClient.get_notes_by_tieba_name] Extracted {len(notes)} posts")
return notes
except Exception as e:
utils.logger.error(f"[BaiduTieBaClient.get_notes_by_tieba_name] Failed to get Tieba post list: {e}")
raise
async def get_creator_info_by_url(self, creator_url: str) -> TiebaCreator:
"""
Get creator information by creator URL from current PC JSON API.
Args:
creator_url: Creator homepage URL
Returns:
TiebaCreator: Creator information
"""
if not self.playwright_page:
utils.logger.error("[BaiduTieBaClient.get_creator_info_by_url] playwright_page is None, cannot use browser mode")
raise Exception("playwright_page is required for browser-based creator info fetching")
portrait = self._extract_creator_portrait(creator_url)
if not portrait:
raise Exception(f"Can not extract Tieba creator portrait from url: {creator_url}")
utils.logger.info(
f"[BaiduTieBaClient.get_creator_info_by_url] Accessing creator info API, portrait: {portrait}"
)
try:
api_data = await self._fetch_json_by_browser(
"/c/u/pc/homeSidebarRight",
params={
"portrait": portrait,
"un": "",
"subapp_type": "pc",
"_client_type": "20",
},View on GitHub (pinned to d6f7c5bb90)
Solutions
- Attach a live Playwright page to the client before calling creator methods
- Verify browser launch succeeded and login finished before the creator crawl stage starts
- In tests, inject a mock page implementing goto/content/evaluate
Defensive patterns
Strategy: type-guard
Validate before calling
if not client.playwright_page:
raise RuntimeError("creator crawl requires an attached Playwright page") Type guard
def creator_crawl_ready(client) -> bool:
p = getattr(client, "playwright_page", None)
return p is not None and not p.is_closed() Prevention
- Sequence creator crawls after login/browser setup completes
- Detect closed pages and re-create the browser context mid-run
When it happens
Trigger: Calling get_creator_info_by_url(creator_url) on a client constructed without playwright_page, e.g. creator crawl started before the browser context exists or after it was closed.
Common situations: Creator-crawl pipelines (TIEBA_CREATOR_ID_LIST config) run without completing the login/browser bootstrap; browser crash leaving a stale client; headless test environments missing Playwright.
Related errors
- playwright_page is required for browser-based creator notes
- 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 tieba note fet
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/05694e356cad299c.
Report an issue: GitHub.