使用python-whois模块查询域名信息

来源:转载

一,简介

通过域名注册信息,可以知道一个网站背后的公司信息,这个还是很厉害的,你用其他语言想查询这个,不好下手吧?


Python直接提供了成熟的模块,就是这么锋利,它就是python-whois模块。


二,模块安装

在终端命令行执行pip install python-whois即可,注意需要使用root用户执行安装命令。


三,查询域名信息

利用whois模块的whois方法(有点绕口啊,其实有点类似Java里面Whois类的whois方法)可以直接查询域名信息,当然这是需要联网的哦。


如下所示,查出了很多东西,可见看到有Beijing Sohu New Media Information Technology Co. Ltd,所以该域名应该是北京搜狐新媒体信息技术有限责任公司。(这个英语水平挺溜)


[[email protected] /]# python
Python 2.7.5 (default, Nov6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import whois
>>> whois.whois("sohu.com")
{u'updated_date': [datetime.datetime(2017, 7, 17, 13, 11, 19), datetime.datetime(2017, 7, 16, 21, 56, 57)], u'status': [u'clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited', u'clientTransferProhibited https://icann.org/epp#clientTransferProhibited', u'clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited', u'serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited', u'serverTransferProhibited https://icann.org/epp#serverTransferProhibited', u'serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited', u'clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)', u'clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)', u'clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)', u'serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)', u'serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)', u'serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)'], u'name': u'Domain Admin', u'dnssec': u'unsigned', u'city': u'Beijing', u'expiration_date': [datetime.datetime(2019, 7, 4, 4, 0), datetime.datetime(2019, 7, 3, 21, 0)], u'zipcode': u'100190', u'domain_name': [u'SOHU.COM', u'sohu.com'], u'country': u'CN', u'whois_server': u'whois.markmonitor.com', u'state': u'Beijing', u'registrar': u'MarkMonitor, Inc.', u'referral_url': None, u'address': u'No.2 Kexueyuan South Road, Haidian District', u'name_servers': [u'NS11.SOHU.COM', u'NS12.SOHU.COM', u'NS13.SOHU.COM', u'NS14.SOHU.COM', u'NS15.SOHU.COM', u'NS16.SOHU.COM', u'ns11.sohu.com', u'ns13.sohu.com', u'ns14.sohu.com', u'ns12.sohu.com', u'ns15.sohu.com', u'ns16.sohu.com'], u'org': u'Beijing Sohu New Media Information Technology Co. Ltd', u'creation_date': [datetime.datetime(1998, 7, 5, 4, 0), datetime.datetime(1998, 7, 4, 21, 0)], u'emails': [u'[email protected]', u'[email protected]']}

分享给朋友:
您可能感兴趣的文章:
随机阅读: