[Pythonmac-SIG] Problems with urllib2 and MacPython2.2.1
Tony Lownds
tony@metanet.com
Fri, 19 Apr 2002 12:51:19 -0700
FYI: works from CVS too
ironchef:~% python
Python 2.3a0 (#5, Apr 15 2002, 14:24:59)
[GCC 2.95.2 19991024 (release)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> f = urllib.urlopen('http://www.google.com/')
>>> print f.headers
Content-Length: 2402
Connection: Close
Server: GWS/2.0
Date: Fri, 19 Apr 2002 19:37:43 GMT
Content-Type: text/html
Cache-control: private
Set-Cookie:
PREF=ID=550613584a737c73:TM=1019245063:LM=1019245063:S=wtOcPy0G6Q0;
domain=.google.com; path=/; expires=Sun, 17-Jan-2038 19:14:07 GMT
>>> print f.readlines()
[...snip...]
>>> f.close()
-Tony
At 12:25 PM -0700 4/19/02, Daniel Burr wrote:
>Greetings,
>
>I've just recently switched from Windows to Mac OS X, and am having
>some problems with both urllib and urllib2 on OS 10.1.3. The
>problem occurs both with MacPython2.2.1 and with Python2.2.1
>compiled from the Unix sources.
>
>Basically, urlopen() does not work for me with either urllib or
>urllib2, as the file-like object being returned throws errors when I
>try to call readlines(). The code below works perfectly with the
>python2.1_macosx.tgz distribution from Tony Lownds' site. I have
>not yet installed and tested against MacPython2.1.
>
>Example:
>import urllib
>f = urllib.urlopen('http://www.google.com/')
>print f.headers
>print f.readlines()
>f.close()
>
>The example above will throw an error as soon as it hits the
>readlines() call. Any ideas? I have not heard any mention of this
>problem prior to now, so I am thinking I must be doing something
>very wrong.
>
>Any advice gratefully accepted.
>
>Daniel Burr
>
>
>_______________________________________________
>Pythonmac-SIG maillist - Pythonmac-SIG@python.org
>http://mail.python.org/mailman/listinfo/pythonmac-sig
--