SOK
SOK

Reputation: 1792

How to download multiple files wiht the same name with wget in python

I am trying to download multiple files using wget but because they have the same name, each time a file is downloaded it replaces the previously downloaded file.

my current code is:

import wget
for link in links:
    wget.download(link ,r'C:\Users\xxx\xxx\xxx\xxx')

Is there a way you can get it to automatically change the name so the next file can be downloaded? It doesn't matter what name. Thanks!

Upvotes: 0

Views: 1142

Answers (1)

malisit
malisit

Reputation: 1258

try this, it basically adds a number at the end of each file and thus makes their names different.

for c, link in enumerate(links):
    wget.download(link ,r'C:\Users\xxx\xxx\xxx\xxx' + str(c))

Upvotes: 2

Related Questions