Downloading files using URLLib
A. Murat Eren
meren at uludag.org.tr
Mon Jun 27 08:40:50 EDT 2005
Hi,
On Monday 27 June 2005 12:10, Oyvind Ostlund wrote:
> I have to download a lot of files. And at the moment i am trying with
> URLLib. But sometimes it doesn't download the whole file. It looks like it
> stops half way through or something. Is it possible to ask for the file
> size before you download, and then test afterwards if the whole file was
> read? If so please guid me a bit here.
You need something like that:
import urllib2
URI='http://cekirdek.uludag.org.tr/index.html'
file = urllib2.urlopen(URI)
headers = file.info()
fsize = int(headers['Content-Length'])
HTH..
Ciao,
--
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
A. Murat Eren
meren at uludag.org.tr
http://cekirdek.uludag.org.tr/~meren/
0x527D7293,
7BCD A5A1 8101 0F6D 84A4 BD11 FE46 2B92 527D 7293
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
--
Alan Cox sounds as if he hasn't followed the
development of programming languages
and compilers for the last 10 years (exa).
-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050627/d95e9e64/attachment.sig>
More information about the Python-list
mailing list