Mythus commited on
Commit
756c8e6
·
verified ·
1 Parent(s): 902f3cf

Update script.py

Browse files
Files changed (1) hide show
  1. script.py +20 -11
script.py CHANGED
@@ -1,16 +1,25 @@
1
- from playwright.sync_api import sync_playwright
 
2
 
3
- def run(playwright):
4
  firefox = playwright.firefox
5
- browser = firefox.launch(headless=True)
6
- context = browser.new_context()
7
- page = context.new_page()
8
-
9
- page.goto('https://d000d.com/e/9b3w45p3h2gz')
10
 
11
- print(page.content())
 
 
 
 
12
 
13
- browser.close()
 
 
 
 
14
 
15
- with sync_playwright() as playwright:
16
- run(playwright)
 
1
+ import asyncio
2
+ from playwright.async_api import async_playwright
3
 
4
+ async def run(playwright):
5
  firefox = playwright.firefox
6
+ browser = await firefox.launch(headless=True)
7
+ context = await browser.new_context()
8
+ page = await context.new_page()
9
+
10
+ await page.goto('https://d000d.com/e/9b3w45p3h2gz')
11
 
12
+ # Wait for 5 seconds
13
+ await asyncio.sleep(5)
14
+
15
+ # Get and print the HTML of the page
16
+ print(await page.content())
17
 
18
+ await browser.close()
19
+
20
+ async def main():
21
+ async with async_playwright() as playwright:
22
+ await run(playwright)
23
 
24
+ # Run the function
25
+ asyncio.run(main())