使用python-whois模块查询域名

2023-01-31 05:01:43 python

一,简介

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

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

二,模块安装

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

三,查询域名信息

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

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

[root@localhost /]# python
Python 2.7.5 (default, Nov  6 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'abusecomplaints@markmonitor.com', u'dnsadmin@sohu-inc.com']}

相关文章