从URL /域中检索Whois信息

时间:2017-10-12 21:28:53

标签: python python-2.7 whois

whois模块似乎对我不起作用,运行此代码会给我一个错误

import whois
domains = ['cnn.com']
for dom in domains:
    domain = whois.Domain(dom)
    print domain.registrar 

这会抛出此错误:

  

追踪(最近的呼叫最后):
  文件" C:\ Python27 \ Practice \ 2.py",第5行,在中   domain = whois.Domain(dom)
  文件" C:\ Python27 \ lib \ site-packages \ whois_3_adjust.py",第12行, init
  self.name = data [' domain_name'] [0] .strip()。lower()
  TypeError:字符串索引必须是整数,而不是str

也尝试过这个问题:

import whois
var = whois.query('google.com')
print var

C:\Python27\python.exe C/Test.py
Traceback (most recent call last):
  File "C:/Test.py", line 2, in <module>
    var = whois.query('google.com')
  File "C:\Python27\lib\site-packages\whois\__init__.py", line 50, in query
    pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
  File "C:\Python27\lib\site-packages\whois\_1_query.py", line 44, in do_query
    _do_whois_query(dl, ignore_returncode),
  File "C:\Python27\lib\site-packages\whois\_1_query.py", line 58, in _do_whois_query
    p = subprocess.Popen(['whois', '.'.join(dl)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "C:\Python27\lib\subprocess.py", line 711, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 959, in _execute_child
    startupinfo)
WindowsError: [Error 2] 

Process finished with exit code 1

0 个答案:

没有答案