为什么图片地址,请求都通过了,aiofiles写入文件图片为空啊
试了response.content.read(),还是空
async def download(url,title):
# print(url)
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False),headers=headers)as session:
async with session.get(url=url,ssl=False)as resp:
page_text = await resp.read()
print(resp.status,url)
# with open(f'./唯美小姐姐图片/{title}.jpeg',mode="wb")as f:
# f.write(resp.content.read())
async with aiofiles.open(f'./唯美小姐姐图片/{title}.jpg',mode="wb")as f:
f.write(page_text)
print(title,"下载完毕!")


最后
以上就是老实刺猬最近收集整理的关于初学爬虫,对aiohttp和aiofiles模块有些困惑的全部内容,更多相关初学爬虫内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复