I can be given a string in any of these formats:
url: e.g http://www.acme.com:456
string: e.g www.acme.com:456, www.acme.com 456, or www.acme.co
You can use urlparse to get hostname from URL string:
from urlparse import urlparse print urlparse("http://www.website.com/abc/xyz.html").hostname # prints www.website.com