[Tutor] reading webpage

Guess?!? wtfwhoami at gmail.com
Tue Feb 19 06:12:36 CET 2008


Hi Kent,

Broken machine gives

IDLE 1.2.1
>>> import urllib
>>> print urllib.getproxies()
{'http': 'http://proxy-address:port'}
>>>

correct machine gives empty dictionary ... { }

Thanks
Gagan Arora

On Feb 18, 2008 7:26 PM, Kent Johnson <kent37 at tds.net> wrote:

> Guess?!? wrote:
> > Hi All,
> >
> > I am trying to read a webpage into a variable. My intention is to search
> > for patterns within the page. I am stuck because I get this error shown
> > below ....
> > I have 2.5.1 Windows installer. I have tried repairing it but it takes
> > me down in the same hole ...everything else seems to work fine in python
> > Anyone else who encountered similar problem?
>
> A wild guess is that you have a mis-configured proxy on the broken
> machine. Try this on both machines:
> import urllib
> print urllib.getproxies()
>
> Kent
>
> >
> > Funny thing is it works on my second computer :-|
> >
> > Thanks
> > Gagan
> >
> >  >>> import urllib
> >  >>> sock = urllib.urlopen("http://www.cnn.com/")
> > Traceback (most recent call last):
> >   File "<pyshell#16>", line 1, in <module>
> >     sock = urllib.urlopen("http://www.cnn.com/")
> >   File "C:\Python25\lib\urllib.py", line 82, in urlopen
> >     return opener.open(url)
> >   File "C:\Python25\lib\urllib.py", line 190, in open
> >     return getattr(self, name)(url)
> >   File "C:\Python25\lib\urllib.py", line 314, in open_http
> >     h = httplib.HTTP(host)
> >   File "C:\Python25\lib\httplib.py", line 1155, in __init__
> >     self._setup(self._connection_class(host, port, strict))
> >   File "C:\Python25\lib\httplib.py", line 635, in __init__
> >     self._set_hostport(host, port)
> >   File "C:\Python25\lib\httplib.py", line 647, in _set_hostport
> >     raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
> > InvalidURL: nonnumeric port: 'port'
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080218/59932015/attachment.htm 


More information about the Tutor mailing list