Update playwright/README.md
This commit is contained in:
@@ -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()
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user