Hostname

Alex Martelli aleax at mail.comcast.net
Sun Jan 29 20:14:13 CET 2006


jonas.bruechner at googlemail.com <jonas.bruechner at googlemail.com> wrote:

> Hi
> Iam new in Python.
> I want to know for my first Project in Python how i can get the
> Hostname from a URL?

>>> import urlparse
>>> urlparse.urlsplit('http://foo.bar.com/zapzap')
('http', 'foo.bar.com', '/zapzap', '', '')
>>> 

As you may notice, the hostname is the second item of the tuple result.

> Thanks for Help

You're welcome.


Alex



More information about the Python-list mailing list