import asyncio
import aiohttp
async def run(url):
print(“开始执行爬虫…”,url)
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
print(resp.url)
url_list = [“https://www.baidu.com”,“https://mengsec.com”]
tasks = [asyncio.ensure_future(run(url)) for url in url_list]
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(tasks))