[Tutor] reading webpage

Guess?!? wtfwhoami at gmail.com
Tue Feb 19 02:46:39 CET 2008


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?

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'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080218/4b60fb30/attachment.htm 


More information about the Tutor mailing list