Итак, я впервые с драматургом, поэтому я подумал, что попробовать примеры только для того, чтобы найти ни одной из работ, и ошибки не имеют смысла: < /p>
Я пробовал все примеры В документах и на страницах GitHub и продолжайте получать ошибки, которые я просто не понимаю.
cod >
from playwright.sync_api import sync_playwright
playwright = sync_playwright().start()
browser = playwright.chromium.launch()
page = browser.new_page()
page.goto("https://playwright.dev/")
page.screenshot(path="example.png")
browser.close()
playwright.stop()
< /code>
`
** Ошибка:
** < /p>
---------------------------------------------------------------------------
Error Traceback (most recent call last)
Cell In[23], line 3
1 from playwright.sync_api import sync_playwright
----> 3 playwright = sync_playwright().start()
5 browser = playwright.chromium.launch()
6 page = browser.new_page()
File ~/Downloads/Packaging Industry Anomaly DEtection (PIADE)/venv/lib/python3.12/site-packages/playwright/sync_api/_context_manager.py:84, in PlaywrightContextManager.start(self)
83 def start(self) -> SyncPlaywright:
---> 84 return self.__enter__()
File ~/Downloads/Packaging Industry Anomaly DEtection (PIADE)/venv/lib/python3.12/site-packages/playwright/sync_api/_context_manager.py:47, in PlaywrightContextManager.__enter__(self)
45 self._own_loop = True
46 if self._loop.is_running():
---> 47 raise Error(
48 """It looks like you are using Playwright Sync API inside the asyncio loop.
49 Please use the Async API instead."""
50 )
52 # Create a new fiber for the protocol dispatcher. It will be pumping events
53 # until the end of times. We will pass control to that fiber every time we
54 # block while waiting for a response.
55 def greenlet_main() -> None:
Error: It looks like you are using Playwright Sync API inside the asyncio loop.
Please use the Async API instead.
Подробнее здесь: https://stackoverflow.com/questions/787 ... yncio-loop
Playwright Sync API в петле Asyncio ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение