The sockets module provides an easy way to look up a host name’s ip address.
import socket addr1 = socket.gethostbyname('google.com') addr2 = socket.gethostbyname('yahoo.com') print(addr1, addr2)
- Python Style Rules
- How to Find Your External IP address
- Writing Your First Python Django Application
Which will output the following IP addresses: