Python async异步编程爬取图片
from functools import wraps
import aiofiles
import aiohttp
import asyncio
import time
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36'
}
async def spider_img(url):
async with aiohttp.ClientSession() as session:
response=await session.get(headers=headers, url=url)
content_img = await response.content.read()
async with aiofiles.open(fr'./photo/{
time