urllib2 bug?

bob sacamano jd33526 at gmail.com
Fri Jul 29 19:03:38 EDT 2005


Certain pages cause urllib2 to go into an infinite loop when using
readline(), but everything works fine if read() is used instead. Is
this a bug or am I missing something simple?

import urllib2

url = 'http://www.naylamp.com'

f = urllib2.urlopen(url)

i = 0

#this works fine when uncommented
#print f.read()
#print 'finished'

#this never ends
while 1:
    line = f.readline()
    if not line:
        break
    print line
    print i
    i = i + 1
#end while




More information about the Python-list mailing list