python查询域名whois信息

可以使用第三方模块whois来查询域名的whois信息,安装方法如下:

```python
!pip install python-whois
```

查询代码示例:

```python
import whois

domain = 'example.com'
w = whois.whois(domain)
print(w)
```

输出结果示例:

```
{
  "domain_name": [
    "EXAMPLE.COM",
    "example.com"
  ],
  "registrar": "Tucows Domains Inc.",
  "whois_server": "whois.tucows.com",
  "referral_url": null,
  "updated_date": [
    "2020-04-14 18:55:13",
    "2021-03-18 13:28:10"
  ],
  "creation_date": "1995-08-14 04:00:00",
  "expiration_date": "2023-08-13 04:00:00",
  "name_servers": [
    "A.IANA-SERVERS.NET",
    "B.IANA-SERVERS.NET"
  ],
  "status": [
    "clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited",
    "clientTransferProhibited https://icann.org/epp#clientTransferProhibited",
    "clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited",
    "serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited",
    "serverTransferProhibited https://icann.org/epp#serverTransferProhibited",
    "serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited"
  ],
  "emails": [
    "abuse@tucows.com",
    "domainabuse@tucows.com"
  ],
  "dnssec": "unsigned",
  "name": null,
  "org": "Internet Corporation for Assigned Names and Numbers",
  "address": null,
  "city": null,
  "state": "CA",
  "zipcode": null,
  "country": "US"
}
```

相关代码参考