import asyncio
from playwright.async_api import async_playwright
async def run(url):
async with async_playwright() as playwright:
chromium = playwright.chromium
browser = await chromium.launch(headless=False)
user_context = await browser.new_context()
page = await user_context.new_page()
await page.goto(url)
async def main():
tasks =[]
urls = ['https://www.baidu.com','https://www.taobao.com','https://www.jd.com']
for url in urls:
task = asyncio.ensure_future(run(url))
tasks.append(task)
await asyncio.gather(*tasks)
if __name__ == '__main__':
asyncio.run(main())