How do I 'stat' online files?
gagsl-py2 at yahoo.com.ar
Thu Jul 26 03:05:15 CEST 2007
En Wed, 25 Jul 2007 15:11:19 -0300, Carsten Haese <carsten at uniqsys.com>
> On Tue, 2007-07-24 at 22:23 -0300, Gabriel Genellina wrote:
>> En Tue, 24 Jul 2007 10:47:16 -0300, Carsten Haese <carsten at uniqsys.com>
>> > On Tue, 2007-07-24 at 09:07 -0400, DB Daniel Brown wrote:
>> >> I am working on a program that needs to stat files (gif, swf, xml,
>> >> dirs, etc) from the web. I know how to stat a local file…
>> > That's because urlopen returns a file-like object, not a file. The
>> > you can hope for is to inspect the headers that the web server
>> >>>> f = urllib.urlopen("http://www.python.org")
>> This generates an HTTP GET request - transfering the contents too,
> Yes, but how much of that content will actually be transferred if I
> don't call f.read?
Transferred? The server perhaps has sent all of it, depending on its
configuration and available bandwidth. The first packets will be in your
TCP receiving buffers even if you never call f.read(). So be nice to the
origin server, the whole Internet, and our planet, and don't waste
bandwidth and energy in requesting things that you're going to throw away
> I doubt that my computer just downloaded 4 MB of stuff in 0.3 seconds.
Probably not, but I'd use netstat or ntop to find out how much has
actually been downloaded.
More information about the Python-list