Analizar una URL para la dirección IP con Python

from urllib.parse import urlparse, parse_qs
import socket


url = 'http://example.com/x/y?a=1&b=2'

# Parse the URL
parsed = urlparse('http://example.com/x/y?a=1&b=2&a=3')

# For the parameters
params = parse_qs(parsed.query)
print(params)

# For path components
# Note: Depending on the URL, this may have empty strings so that's why the
# filter is used
path_components = list(filter(bool, parsed.path.split('/')))
print(path_components)

# Location
print(parsed.netloc)

# IP
print(socket.gethostbyname(parsed.netloc))
Wild Wolf