Downloading files using urllib in a for loop?
Martin Franklin
mfranklin1 at gatwick.westerngeco.slb.com
Wed Feb 15 05:54:21 EST 2006
justsee at gmail.com wrote:
> Thanks - but have printed and verified they are valid paths and
> filenames. One correction to the code I listed:
> theurl = imagepath[:-8]
>
> For some reason the values aren't being passed through
> urllib.urlretrieve properly but this makes no sense to me?
>
A working (for me!) example:-
import urllib
paths = ["http://www.python.org/index.html", ]
for remotepath in paths:
# keep only last 10 chars (index.html)
# for local file name
localpath = remotepath[-10:]
print remotepath, localpath
urllib.urlretrieve(remotepath, localpath)
More information about the Python-list
mailing list