20.multi_case04

import aiohttp
import asyncio
import ssl

async def fetch(session, url):
    async with session.get(url,ssl=ssl.SSLContext()) as response:
        return await response.text()

async def main():
    async with aiohttp.ClientSession() as session:
        html = await fetch(session,'http://www.baidu.com')
        print(html)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
posted @ 2019-05-06 16:50  hank-li  阅读(118)  评论(0)    收藏  举报