ken wrote:
Hi,
When I call urlopen.read() like this:
data = urlopen("http://localhost").read().
Does that mean I will read the whole document to data, regardless how
many data being sent back?
Thank you.
Yes. However you can read (and presumably process)one line at a time
with readline() or by iterating over the object returned by urlopen().
I'd recommend trying something like:
u = urlopen("http://localghost/")
for line in u:
print line # or process it some other way
or
line = u.readline()
while line:
# process the line
line = u.readline()
There is no need to buffer the whole content before you process it
unless you choose to do so.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd
http://www.holdenweb.com
Skype: holdenweb
http://del.icio.us/steve.holden
Recent Ramblings
http://holdenweb.blogspot.com