playwright: initial example
This commit is contained in:
28
playwright/README.md
Normal file
28
playwright/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
```python
|
||||
# pip install playwright && playwright install --with-deps chromium
|
||||
|
||||
def GET(url):
|
||||
html = __import__('queue').Queue()
|
||||
def tGET():
|
||||
async def aGET():
|
||||
from playwright.async_api import async_playwright
|
||||
async with async_playwright() as playwright:
|
||||
browser = await playwright.chromium.launch()
|
||||
page = await browser.new_page()
|
||||
html.put(await page.goto(url) and await page.content())
|
||||
__import__('asyncio').run(aGET())
|
||||
__import__('threading').Thread(target=tGET).start()
|
||||
return html.get()
|
||||
|
||||
# 사용 예
|
||||
html = GET('https://www.freeproxy.world/')
|
||||
print(html)
|
||||
|
||||
# Output:
|
||||
"""
|
||||
<!DOCTYPE html><html lang="en"><head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<title>FreeProxy.World - Free Proxy List</title>
|
||||
"""
|
||||
```
|
||||
Reference in New Issue
Block a user