import aiohttp
import asyncio
urls = [
"https://images.quanjing.com/170/thu/pc041-04.jpg",
"https://images.quanjing.com/Chineseview005/thu/1S-1095.jpg",
"https://images.quanjing.com/chineseview019/thu/27-0270.jpg"
]
async def adownload(url):
name = url.rsplit("/", 1)[1]
async with aiohttp.ClientSession as session:
async with session.get(url) as resp:
with open(name, mode="wb") as f:
f.write(await resp.content.read())
print(name, "over!!!")
async def main():
tasks = []
for url in urls:
tasks.append(adownload(url))
if __name__ == "__main__":
asyncio.run(main())