Update playwright/README.md

This commit is contained in:
2025-02-03 21:16:39 +00:00
parent ff70df1b4b
commit 9a3ae8ed67

View File

@@ -29,4 +29,27 @@ def Page():
page = Page() page = Page()
page.goto('google.com') page.goto('google.com')
page page
```
# IPython on Windows
```python
def thread(func):
import asyncio, concurrent
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
return lambda: concurrent.futures.ThreadPoolExecutor().submit(func).result()
def handle(route):
print(route.request.url)
route.continue_()
@thread
def main():
from playwright.sync_api import sync_playwright
with sync_playwright() as playwright:
(page := playwright.firefox.launch().new_page()).set_default_timeout(0)
page.route('**/*', handle)
page.goto('https://google.com')
main()
``` ```