[Tutor] reading webpage

Kent Johnson kent37 at tds.net
Tue Feb 19 04:26:29 CET 2008


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



More information about the Tutor mailing list