Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Selenium中选择图像_Python_Selenium_Web Scraping - Fatal编程技术网

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才能工作。

仅第一个是什么意思?图像?