[2.5.1] Script to download and rename bunch of files?

Laurent Claessens moky.math at gmail.com
Fri Apr 8 09:14:27 EDT 2011


Le 08/04/2011 14:47, Gilles Ganault a écrit :
> Hello,
>
> 	Before I go ahead and learn how to write this, I was wondering if
> someone knew of some source code I could use to download and rename a
> bunch of files, ie. the equivalent of wget's -O switch?
>
> I would provide a two-column list where column 1 would contain the
> full URL, and column 2 would contain the name to use to rename the
> file once downloaded.
>
> Thank you.

The following puts in the string `a` the code of the page urlBase :

a = urllib.urlopen(urlBase).read()

Then you have to write `a` in a file.

There could be better way.

Laurent



More information about the Python-list mailing list