Im trying to have python extract some text out of URL string.
Here's example of URL https://somewebsite/images/products/SkuName/genricFileName.jpg
The SkuName always will come after the 5th "/" and will end by the 6th "/"
I would like to extract 'SkuName'
import urllib.request
images = input('please enter url list separated by ","')
names = input('please enter images names separated by ","')
images = images.split(',')
names = names.split(',')
for index, image in enumerate(images):
urllib.request.urlretrieve(image, "images/{}.jpg".format(names[index]))
print('images downloaded successfully')
As you can see, the user have to manually enter the SKU Name (which goes under variable 'names')
I would like the user to enter only one input (URL) and python automatically extract the SKUName out of the URL string
Thanks!