Три петли для каждого массива. Просто зациклируйте каждый массив и добавьте новый массив.
var size = ['s','m'];
var color = ['red','blue','black'];
var material = ['cotton','linen'];
var arrayMaterials = []
for (var i = 0; i < size.length; i++) {
for (var j = 0; j < color.length; j++) {
for (var k = 0; k < material.length; k++) {
arrayMaterials.push(size[i] + "," + color[j] + "," + material[k]);
}
}
}
console.log(arrayMaterials);
HTML для изображения не отображается в Javascript, поэтому вам не нужен селен. используйте Beautifulsoup с re.compile
для соответствия href
в элементе a
, который начинается с /ItemImages/
.
обратите внимание, что используется относительный URL-адрес, необходимый для добавления домена к URL-адресу изображений.
base_url = 'https://auctions.morphyauctions.com'
url = base_url + "/French_Fashion_Doll_with_Unusual_Body_-LOT450029.aspx"
html = requests.get(url).text
sel_soup = BeautifulSoup(html, 'html.parser')
images = []
for a in sel_soup.findAll('a', href=re.compile(r'^/ItemImages/')):
ahref = base_url + a['href'] # wee need to append the domain here
images.append(ahref)
print(images)
current_path = os.getcwd()
for img in images:
try:
file_name = os.path.basename(img)
img_r = requests.get(img)
new_path = os.path.join(current_path, 'images', file_name)
with open(new_path, 'wb') as output_file:
output_file.write(img_r.content)
except:
print(ex)