码
import socket
line = 'http://www.permobil.com/en/Corporate/'
IP = socket.gethostbyname(line)
错误
IP = socket.gethostbyname(line)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
答案 0 :(得分:0)
试试这个:
import socket
ip = socket.gethostbyname("permobil.com")
print ip
答案 1 :(得分:0)
import socket
from urlparse import urlparse
parsed_uri = urlparse('http://www.permobil.com/en/Corporate/' )
domain = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri)
domain = domain.replace("http://","")
domain = domain.replace("www.", "")
domain = domain.replace("/", "")
IP = socket.gethostbyname(domain)