Python 如何在Selenium中选择图像
我需要下载这六个图片在这个链接在缩放版本Python 如何在Selenium中选择图像,python,selenium,web-scraping,Python,Selenium,Web Scraping,我需要下载这六个图片在这个链接在缩放版本 但是如果你看一下HTML,你会发现只有第一个处于选中模式。我只需点击其余部分,将类更改为selected,然后下载所有内容。如何使用selenium自动执行此操作?在页面中,您可以从预览图像中获取原始图像源 previewImages = driver.find_elements_by_xpath("//div[@class='previews']//img") for origImages in previewImages: previewu
但是如果你看一下HTML,你会发现只有第一个处于选中模式。我只需点击其余部分,将类更改为selected,然后下载所有内容。如何使用selenium自动执行此操作?在页面中,您可以从预览图像中获取原始图像源
previewImages = driver.find_elements_by_xpath("//div[@class='previews']//img")
for origImages in previewImages:
previewurl=origImages.get_attribute("src")
local_image_filename = wget.download(previewurl.replace("?preset=productalt",""))
print(local_image_filename)
上面的代码从预览图像中获取原始图像url,并使用wget下载它们。您需要导入wget才能工作。仅第一个是什么意思?图像?