Milad Rasooli
Milad Rasooli

Reputation: 1

I get an error when I try to get a site in Python

import whois
site = input('enter site : ')
M = whois.whois(site)
print(M)

When I input, enter site : google.com

I got following response (error):

Traceback (most recent call last):
  File "f:/Programming/project/Project/whois.py", line 1, in <module>
    import whois
  File "f:\Programming\project\Project\whois.py", line 4, in <module>
    M = whois.whois(site)
TypeError: 'module' object is not callable

Upvotes: -1

Views: 113

Answers (2)

Holloway
Holloway

Reputation: 7377

Your file is called whois.py. When you import whois you are importing your file not the package you think you are. Running whois.whois(...) you are calling yourself as a function.

Rename your file and try again.

Upvotes: 1

user107511
user107511

Reputation: 822

try:

M = whois.query(site)
print(M.__dict__)

query is the method to get the site whois data

Upvotes: 1

Related Questions