title: Check whether domain is registered
body: <p>I'm trying to make a script that returns unregistered domains. I'm working in Python 2.7. I've read that the module <code>whois</code> should be able to do that but the code I've written raises an error. </p>
  
  <p>Code:</p>
  
  <pre><code>import whois
  domains = ['http://www.example.com']
  
  for dom in domains:
      domain = whois.Domain(dom)
      print domain.registrar 
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>  domain = whois.Domain(dom)
    File "C:\Python27\lib\site-packages\whois\_3_adjust.py", line 12, in __init__
      self.name               = data['domain_name'][0].strip().lower()
  TypeError: string indices must be integers, not str
  </code></pre>
  
  <p>Have you any idea what could be wrong? Or can you give me a better solution? </p>
  
  <p>EDIT: I tried the pythonwhois module but it returns an error too.</p>
  
  <p>EDIT2: According to one solution here, on SO, I've tried to use <code>pywhois</code>, this code raises an error too. </p>
  
  <pre><code>import pywhois
  w = pywhois.whois('google.com')
  w.expiration_date
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>w = pywhois.whois('google.com')
  AttributeError: 'module' object has no attribute 'whois'
  </code></pre>