urllib2 bug?

Discussion in 'Python' started by bob sacamano, Jul 30, 2005.

  1. bob sacamano

    bob sacamano Guest

    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
     
    bob sacamano, Jul 30, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kylotan

    urllib2 for HTTPS/SSL

    Kylotan, Jul 8, 2003, in forum: Python
    Replies:
    5
    Views:
    567
    Jeremy Hylton
    Jul 9, 2003
  2. John J. Lee

    Re: urllib2 http status

    John J. Lee, Jul 29, 2003, in forum: Python
    Replies:
    1
    Views:
    2,507
    rosendo
    Jul 31, 2003
  3. O. Koch

    FTP with urllib2 behind a proxy

    O. Koch, Aug 7, 2003, in forum: Python
    Replies:
    4
    Views:
    1,299
    John J. Lee
    Aug 14, 2003
  4. Replies:
    1
    Views:
    493
    Fuzzyman
    Jul 27, 2005
  5. Josef Cihal
    Replies:
    0
    Views:
    763
    Josef Cihal
    Sep 5, 2005
Loading...

Share This Page