在使用playwright时报NotImplementedError错误,是怎么回事啊
代码:
js = """
Object.defineProperties(navigator, {webdriver:{get:()=>undefined}});
"""
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context(
storage_state='state.json') # storage_state='state.json'
page = context.new_page()
page.add_init_script(js)
page.goto(url)
page.wait_for_timeout(2000)
报错信息:
[2024-07-30 14:22:24][asyncio.default_exception_handler():1707] [ERROR] Future exception was never retrieved
future: <Future finished exception=NotImplementedError()>
Traceback (most recent call last):
File "D:\2.py", line 110, in run
self.main(i.old_title)
File "D:\2.py", line 38, in main
html_text = self.captcha.run(url_)
File "D:\auto_pw.py", line 392, in run
with sync_playwright() as playwright:
File "D:\admin\.venv\lib\site-packages\playwright\sync_api\_context_manager.py", line 77, in __enter__
dispatcher_fiber.switch()
File "D:\admin\.venv\lib\site-packages\playwright\sync_api\_context_manager.py", line 56, in greenlet_main
self._loop.run_until_complete(self._connection.run_as_sync())
File "D:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "D:\admin\.venv\lib\site-packages\playwright\_impl\_connection.py", line 263, in run_as_sync
await self.run()
File "D:\django-vue-admin\.venv\lib\site-packages\playwright\_impl\_connection.py", line 272, in run
await self._transport.connect()
File "D:\admin\.venv\lib\site-packages\playwright\_impl\_transport.py", line 133, in connect
raise exc
File "D:\admin\.venv\lib\site-packages\playwright\_impl\_transport.py", line 120, in connect
self._proc = await asyncio.create_subprocess_exec(
File "D:\Program Files\Python38\lib\asyncio\subprocess.py", line 236, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
File "D:\Program Files\Python38\lib\asyncio\base_events.py", line 1630, in subprocess_exec
transport = await self._make_subprocess_transport(
File "D:\Program Files\Python38\lib\asyncio\base_events.py", line 491, in _make_subprocess_transport
raise NotImplementedError
NotImplementedError