The following example shows how to use aiohttp to handle HTTP requests. We’ll send an HTTP GET request to the https://ip.example.com web page. After receiving the request, the web page returns the IP address of the requester. 

Let’s start by creating the get_response() async function:

async def get_response():

    async with aiohttp.ClientSession() as session:

        async with session.get( 'https://ip.example.com/' ) as response:

            print('Status Code: ', response.status)

            print('Body: ', await response.text())