鱼C论坛

 找回密码
 立即注册
查看: 1444|回复: 4

[已解决]python whois怎么用

[复制链接]
发表于 2020-1-15 14:18:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
书上说可以使用whois查询域名的注册者,我输入以下代码已知报错
  1. import whois

  2. print(whois.whois('appspot.com'))
复制代码


Traceback (most recent call last):
  File "D:/pycharm/code/listTest.py", line 3, in <module>
    print(whois.whois('appspot.com'))
AttributeError: module 'whois' has no attribute 'whois'


这是什么原因
最佳答案
2020-1-15 14:34:15
错误提示:没找到whois模块。
应该是模块安装错误了。
安装的时候,用的指令是不是:pip install whois
正常指令应该是pip install python-whois
不知道是不是这个问题。若是的话,你可以尝试以下指令,卸掉旧的,安装新的
pip uninstall whois
pip install python-whois
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-1-15 14:31:26 | 显示全部楼层
用法:
  1. Help on package whois:

  2. NAME
  3.     whois - Python module/library for retrieving WHOIS information of domains.

  4. DESCRIPTION
  5.     By DDarko.org  ddarko@ddarko.org  http://ddarko.org/
  6.     License MIT  http://www.opensource.org/licenses/mit-license.php
  7.    
  8.     Usage example
  9.     >>> import whois
  10.     >>> domain = whois.query('google.com')
  11.    
  12.     >>> print(domain.__dict__)
  13.     {'expiration_date': datetime.datetime(2020, 9, 14, 0, 0), 'last_updated': datetime.datetime(2011, 7, 20, 0, 0), 'registrar': 'MARKMONITOR INC.', 'name': 'google.com', 'creation_date': datetime.datetime(1997, 9, 15, 0, 0)}
  14.    
  15.     >>> print(domain.name)
  16.     google.com
  17.    
  18.     >>> print(domain.expiration_date)
  19.     2020-09-14 00:00:00

  20. PACKAGE CONTENTS
  21.     _1_query
  22.     _2_parse
  23.     _3_adjust
  24.     exceptions
  25.     tld_regexpr

  26. FUNCTIONS
  27.     query(domain, force=0, cache_file=None, slow_down=0, ignore_returncode=0)
  28.         force=1             <bool>      Don't use cache.
  29.         cache_file=<path>   <str>       Use file to store cache not only memory.
  30.         slow_down=0         <int>       Time [s] it will wait after you query WHOIS database. This is useful when there is a limit to the number of requests at a time.

  31. DATA
  32.     CACHE_FILE = None
  33.     SLOW_DOWN = 0
  34.     TLD_RE = {'at': {'creation_date': re.compile('Creation Date:\\s?(.+)',...
复制代码

善用 help
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-1-15 14:34:15 | 显示全部楼层    本楼为最佳答案   
错误提示:没找到whois模块。
应该是模块安装错误了。
安装的时候,用的指令是不是:pip install whois
正常指令应该是pip install python-whois
不知道是不是这个问题。若是的话,你可以尝试以下指令,卸掉旧的,安装新的
pip uninstall whois
pip install python-whois
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-1-15 17:12:30 | 显示全部楼层
hrp 发表于 2020-1-15 14:31
用法:

善用 help

谢谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-1-15 17:13:24 | 显示全部楼层
sunrise085 发表于 2020-1-15 14:34
错误提示:没找到whois模块。
应该是模块安装错误了。
安装的时候,用的指令是不是:pip install whois

确实安装错了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-6-3 06:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表