Python: get domain name from url
December 24, 2009 22:25:38 Last update: December 24, 2009 22:26:11
Use the [url=http://docs.python.org/library/urlparse.html]
The
urlparse[/url] module to parse a URL into parts.
The
urlparse function parses a URL into six components, returning a 6-tuple. This corresponds to the general structure of a URL: scheme://netloc/path;parameters?query#fragment
>>> from urlparse import urlparse >>> parts = urlparse('http://www.google.com/search?hl=en&source=hp&q=python') >>> parts ('http', 'www.google.com', '/search', '', 'hl=en&source=hp&q=python', '') >>>
Easy email testing with http://www.ximailstop.com