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)
            Asked
            
        
        
            Active
            
        
            Viewed 6,152 times
        
    4
            
            
        - 
                    I found this link, not sure how helpful it will be but it deals with reverse DNS, which apparently, a user argues, is more reliable than whois anyways: http://bytes.com/topic/python/answers/46509-whois-like-functionality-windows – rownage Aug 10 '10 at 15:06
 - 
                    That's bogus, whois and DNS are for different things. You can get the name server from DNS, where whois basically only provides a non-authoritative version of the same information. Otherwise, they are for different purposes, and contain different sorts of information, and serve different needs. – tripleee Aug 23 '12 at 06:50
 
2 Answers
6
            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
        
- 854,459
 - 170
 - 1,222
 - 1,395
 
- 
                    It should not be hard to replace this with a pure-Python implementation, though. Basically `telnet whois.internic.net 43` and query for the domain you want, then follow the link it gives you. Hint: `=google.com` works better than `google.com` but there is still quite some amounts of chaff to sort through. – tripleee Aug 23 '12 at 06:52
 
1
            
            
        You could use :
os.system("whois %s" % hostname)
Or use urllib to connect http://www.whois.net and scrap content.
        Guillaume Lebourgeois
        
- 3,796
 - 1
 - 20
 - 23
 
- 
                    
 - 
                    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 Aug 10 '10 at 15:13
 - 
                    
 - 
                    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 Aug 10 '10 at 15:49