import aiohttp
import asyncio
async def fetch(session, url):
async with session.get(url) as response:
return await response.read()
async def main(URL):
async with aiohttp.ClientSession() as session:
for url in URL:
html = await fetch(session, url)
with open('./%s' % url.split('/')[-1].split('?')[0], 'wb') as f:
f.write(html)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
jpg_ = ['https://iterm2.com/downloads/stable/iTerm2-3_3_6.zip']
loop.run_until_complete(main(jpg_))
Python aiohttp簡單入門
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.