I am trying to write a program that (among other things) will receive text or source code from a predefined website. I am learning Python for this, and most sources told me to use urllib2 . As a test, I tried this code:
import urllib2 response = urllib2.urlopen('http://www.python.org') html = response.read()
Instead of acting in any expected way, the shell just sits there, as it waits for input. Not even " >>>" or " ... ". The only way to get out of this state is by using [ctrl] + c. When I do this, I get a whole bunch of error messages like
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/m/mls/pkg/ix86-Linux-RHEL5/lib/python2.5/urllib2.py", line 124, in urlopen return _opener.open(url, data) File "/m/mls/pkg/ix86-Linux-RHEL5/lib/python2.5/urllib2.py", line 381, in open response = self._open(req, data)
I would appreciate any feedback. Is there a tool other than urllib2 to use, or can you give tips on how to fix this. I use a network computer at my work, and I'm not quite sure how the shell is configured or how it can affect anything.
source share