[Python-es] obtener tamaño fichero en URL
Andrey Antoukh
andsux en gmail.com
Mar Feb 7 21:47:26 CET 2012
[niwi en vaio.niwi.be][~]% python2
Python 2.7.2 (default, Nov 21 2011, 17:25:27)
[GCC 4.6.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.head
<function head at 0x15ea1b8>
>>> response = requests.head("
http://mirror.aarnet.edu.au/pub/archlinux/iso/2011.08.19/archlinux-2011.08.19-core-dual.iso
")
>>> response.headers
{'last-modified': 'Fri, 19 Aug 2011 10:24:52 GMT', 'content-length':
'705691648', 'etag': '"501df5-2a100000-4aad923cb6500"', 'date': 'Tue, 07
Feb 2012 20:45:27 GMT', 'accept-ranges': 'bytes', 'content-type':
'application/octet-stream', 'server': 'Apache/2.2.3 (Red Hat)'}
>>> int(response.headers['content-length'])/1024.0/1024.0
673.0
Creo que con esto podria bastarte.
La biblioteca que uso es requests. Puedes instalarla desde pypi.
El día 7 de febrero de 2012 15:34, Julian A. Charon Macias <
julianch en fam.cug.co.cu> escribió:
> Un saludo, como puedo obtener el tamaño(ej. 40 Mb) de un fichero que
este publicado en una direccion URL, mediante Python.
> creo que utilizando el modulo URLLIB, pero no veo como.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Lic. Julián A. Charón Macias
> Tel. : 0294436
> A legendary Informatic
>
>
>
>
>
> UNIVERSIDAD DE GUANTÁNAMO
>
>
> _______________________________________________
> Python-es mailing list
> Python-es en python.org
> http://mail.python.org/mailman/listinfo/python-es
> FAQ: http://python-es-faq.wikidot.com/
--
Andrei Antoukh - <niwi en niwi.be>
http://www.niwi.be/page/about/
http://www.kaleidos.net/A5694F/
"Linux is for people who hate Windows, BSD is for people who love UNIX"
"Social Engineer -> Because there is no patch for human stupidity"
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20120207/d1cf4267/attachment.html>
Más información sobre la lista de distribución Python-es