File size: 530 Bytes
77320e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import httpx
import asyncio
import aiohttp

async def fetch(url: str):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            return await response.text()

async def test_httpx():
    url = 'https://www.example.org/'
    async with httpx.AsyncClient() as client:
        response = await client.get(url)
        print(response)
    return ""

if __name__ == "__main__":
    # asyncio.run(test_httpx())
    text = asyncio.run(fetch('http://www.example.com'))
    print(text)