how to strip the domain name in python?

Michael Bentley michael at jedimindworks.com
Mon Apr 16 05:48:33 CEST 2007


On Apr 15, 2007, at 7:57 PM, Michael Bentley wrote:

>      if net_location[0].lower() == 'www':
>          net_location = net_location[1:]

It is not guaranteed that the host name will be 'www' though, is it?

If you *really* want to strip the host portion of a domain name, I  
suppose you could make calls to whois until you get a match.  For  
instance, a whois lookup on www.cnn.com will not find a match while a  
lookup on cnn.com will.

hth,
Michael



More information about the Python-list mailing list