通过IP38获取域名IP

#!/usr/bin/env python

#coding: utf8

import urllib

from bs4 import BeautifulSoup

import sys

print ("\033[1;35;40m%s\033[0m" %"This format python scriptname domainname")

print ("\033[1;35;40m%s\033[0m" %"For example: python scriptname www.baidu.com")

if len(sys.argv) <=1:

        print "Please Input an valid domainname"

        sys.exit()

domain=sys.argv[1].strip()

url="http://ip38.com/ip.php?ip="+domain

html=urllib.urlopen(url).read()

html=unicode(html,'gb2312').encode("utf8")

soup=BeautifulSoup(html)

list=soup.find('font').find_all('font')

IP=list[0].string

Address=list[1].string

print "Domain %s     IP is:%s       Detial Address:%s"%(domain,IP,Address)

简单的示例一个:

[root@test script]# python ip138.py  www.baidu.com
This format python scriptname domainname
For example: python scriptname www.baidu.com
Domain www.baidu.com     IP is:180.76.3.151       Detial Address:北京市北京百度网讯科技有限公司BGP节点


你可能感兴趣的:(IP38,域名IP信息)