I try to get whois in python. I use this http://code.google.com/p/pywhois/ but it run only in linux. Is it posible to run it on windows? currently i get errors (because internal linux command whois used)
+1
A:
You could use :
os.system("whois %s" % hostname)
Or use urllib
to connect http://www.whois.net and scrap content.
Guillaume Lebourgeois
2010-08-10 15:02:31
Please us `subprocess.Popen` instead of `os.system`
S.Lott
2010-08-10 15:09:48
@Guillaume, your first suggestion (with `subprocess`, not `os.system`) is exactly what `pywhois` uses (on any OS -- see my A with a single line quoted from pywhois's sources), with nice post-processing for parsing the results and making them more usable. You just need a `whois` installed and correctly working -- if your first suggestion works, so will `pywhois`!-)
Alex Martelli
2010-08-10 15:13:08
@S.Lott Why not, but could you explain why ?
Guillaume Lebourgeois
2010-08-10 15:45:10
@Guillaume Lebourgeois: http://www.python.org/dev/peps/pep-0324/ "The subprocess module provides the following enhancements over previous functions:" Summary: `subprocess.Popen` is better than `os.system`
S.Lott
2010-08-10 15:49:15
+2
A:
On Windows just like on Linux, pywhois gives an error if the whois
program is not installed. You could try this whois, for example.
The reason, of course, is in pywhois/init.py, line 11:
r = subprocess.Popen(['whois', domain], stdout=subprocess.PIPE)
Clearly this line needs to run some existing, installed whois
command-line program (which accepts the domain to look up as a commandline argument), whatever OS it's running on.
Alex Martelli
2010-08-10 15:10:40