[Solved] Iterate over a list in python


A simple way is to simply print each string in the returned whois:

host="stackoverflow.com"
whois = pythonwhois.net.get_whois_raw(host)
for item in whois:
    print item

This would output something like this:

Domain Name: STACKOVERFLOW.COM 
Registrar WHOIS Server: whois.name.com 
Registrar URL: http://www.name.com 
Updated Date: 2014-05-09T17:51:17-06:00 
Creation Date: 2003-12-26T19:18:07-07:00 
Registrar Registration Expiration Date: 2015-12-26T19:18:07-07:00 
Registrar: Name.com, Inc. 
Registrar IANA ID: 625 
Registrar Abuse Contact Email: [email protected] 
Registrar Abuse Contact Phone: +1.17202492374 
Reseller:  
Domain Status: clientTransferProhibited 
Registrant Name: Sysadmin Team 
Registrant Organization: Stack Exchange, Inc. 
Registrant Street: 1 Exchange Plaza , Floor 26 
Registrant City: New York 
Registrant State/Province: NY 
Registrant Postal Code: 10006 
Registrant Country: US 
etc.

Anything more elegant than this will require that you use pythonwhois.get_whois(host) and then navigate through the returned dictionary formatting and displaying the fields of interest.

solved Iterate over a list in python