'How to get IP address from aiohttp response

I am have been trying to look into responses from aiohttp requests and have not found a way to get the ipaddress of the specified host:

async with aiohttp.ClientSession() as session:
    async with session.get(f'http://{host}') as response:
        print(response.__dir__())
        #Wanting to get ipaddress of response right here


Solution 1:[1]

I assume your host is represented by a url (otherwise you already have the IP)

So what you need to do is get an ip address by url.
You can do this by:

import socket
print socket.gethostbyname('your hosto name')

your host name is probably 'http://{host}'

Solution 2:[2]

You can use:

async with aiohttp.ClientSession() as session:
    async with session.get(f'http://{host}') as response:
        print(response.connection.transport.get_extra_info('peername'))

source

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 ReVon