Update playwright/README.md
This commit is contained in:
@@ -13,7 +13,7 @@ def _run_once(loop):
|
|||||||
task = (tasks := asyncio.tasks._current_tasks).pop(loop, None)
|
task = (tasks := asyncio.tasks._current_tasks).pop(loop, None)
|
||||||
handle._run(); tasks[loop] = task
|
handle._run(); tasks[loop] = task
|
||||||
(loop := asyncio.get_event_loop()).__class__._run_once = _run_once
|
(loop := asyncio.get_event_loop()).__class__._run_once = _run_once
|
||||||
asyncio.run = loop.run_until_complete; loop.__class__._check_running = lambda _: 0
|
asyncio.run = loop.run_until_complete; loop.__class__._check_running = lambda _: None
|
||||||
|
|
||||||
@(sync := lambda coro: functools.wraps(coro)(
|
@(sync := lambda coro: functools.wraps(coro)(
|
||||||
lambda *args, **kwargs: asyncio.run(coro(*args, **kwargs))))
|
lambda *args, **kwargs: asyncio.run(coro(*args, **kwargs))))
|
||||||
@@ -27,8 +27,7 @@ async def Page(headless=True):
|
|||||||
try:
|
try:
|
||||||
from IPython.display import Image
|
from IPython.display import Image
|
||||||
page.goto = lambda url, goto=page.goto: goto(url) and Image(page.screenshot())
|
page.goto = lambda url, goto=page.goto: goto(url) and Image(page.screenshot())
|
||||||
finally:
|
finally: return page
|
||||||
return page
|
|
||||||
(page := Page()).goto('https://example.org')
|
(page := Page()).goto('https://example.org')
|
||||||
print(page.title()) # Example Domain
|
print(page.title()) # Example Domain
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user