It depends. If you have list of product codes, pictures are in same location and there is always same number of photos then you just add additional layer for looping, something like that (incomplete snippet):
Then for-loop becomes:
If there is variable number of product pictures then you set range to maximum possible pictures and use try... except to catch HTPPError and break out from loop.
skus = ['AMDBNBW', 'AGHJKBW', 'ARTYNBW'] for sku in skus: for x in range(1, 6): website = f'http://img.tennis-warehouse.com/new_big/{sku}-{x}.jpg'If there are several product codes issue of naming downloaded files must be solved. Once again, it depends what do you have. If you have list of desired filenames then you can match them with zip:
skus = ['AMDBNBW', 'AGHJKBW', 'ARTYNBW'] names = ['FRIDAY', 'SATURDAY', 'SUNDAY'] for sku, name in zip(skus, names): for x in range(1, 6): website = f'http://img.tennis-warehouse.com/new_big/{sku}-{x}.jpg' filename = f'{name}-{x}.jpg' urllib.request.urlretrieve(website, filename)If there is no lists and required data must be entered manually then it makes sense to write it in suitable format right away:
record = [('AMDBNBW', 'FRIDAY'),('AGHJKBW', 'SATURDAY'), ('ARTYNBW', 'SUNDAY')]
Then for-loop becomes:
for sku, name in record:
If there is variable number of product pictures then you set range to maximum possible pictures and use try... except to catch HTPPError and break out from loop.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.