Re: Réf. : Re: Help for urllib error : 'no host given'

Steve Holden sholden at holdenweb.com
Thu Apr 12 08:57:01 EDT 2001


<Patrick.Bussi at space.alcatel.fr> wrote in message
news:mailman.987070578.13268.python-list at python.org...
>
> Hi Steve,
>
> Thank you for your investigation. It helps me understand that my python
code is
> correct. I did not forget any character, while the name of the url comes
from
> regex extract of the page returned by the server itself. But you're right
on the
> fact that the name has something wrong, when used in this way.
> I tested the web site "manually", that is pasting the entire name of the
web
> site directly into my Netscape. Same result : "Netscape can't locate the
server.
> No host specified" (this message translated from French)
>
> Therefore the question is : how does it come that a Javascript function
using
> 'document.location="http://blablabla"' is able to redirect my browser to
the
> said web site, and not 'urllib.urlopen("http://blablabla")' ?
>
> More, I do not understand the error message. Does it come from the server
which
> denies the request *or* from the dns which cannot translate the name into
an
> address *or* from Netscape which seems not to receive/understand the host
name ?
>
Essentially it comes from the httplib code, which examines the URL, breaks
it up into various components, and does not find a host component. This is
why I wondered whether you had missed a slash out: "http/hostname" raises
that exact exception.

I would suggest you use urllib to read the URLs. The httplib is mostly
support code for that library.

regards
 Steve







More information about the Python-list mailing list