【问题标题】:Tried to download images with Python lib, but nothing happens and don't get any errors尝试使用 Python lib 下载图像,但没有任何反应,也没有出现任何错误
【发布时间】:2020-02-12 13:50:03
【问题描述】:

我尝试从 Google 图片搜索服务下载图片,但没有成功。我只得到信息: “很遗憾,无法下载全部 20 张图片,因为有些图片无法下载。0 是我们为这个搜索过滤器得到的全部!”我多次运行该应用程序的消息。

错误:零

我下载了 chromedriver,硒存在于我的 VENV 中。我从 Windows / PyCharm Pro 运行这个应用程序。

import time
from google_images_download import google_images_download

search_queries = [
    'Nissan GT-R 2020',
    'Ford Puma 2020',
    'Porsche Macan',
    'VW Touareg 2020'
]

response = google_images_download.googleimagesdownload()

for query in search_queries:
        arguments = {
            "keywords": query,
            "limit": 50,
            "print_urls": True,
            #"size": "medium",
            "output_directory": "E:\\IMAGES",
            "image_directory": f"IMAGES\\{query}",
            "chromedriver": "E:\\IMAGES\\Chrome\\chromedriver.exe"
            }
        paths = response.download(arguments)
        print(paths)
        time.sleep(15)

我在文档中没有看到如何使用 selenium,只有信息,如何添加 chromedriver 路径。

我使用 ChromeDriver 80.0.3987.16 - 比我的 Chrome 浏览器稍旧,版本号以 150 结尾。

【问题讨论】:

    标签: python image selenium selenium-chromedriver


    【解决方案1】:

    确保您可以正常使用driver.get(url)

    检查页面是否使用<iframe>标签(如果使用,则必须使用switch_to.iframe())。

    或者不行,你可以尝试使用WebDriverWait()

    【讨论】:

    • 我会尝试你的建议。但这里我不直接使用 chromedriver 和 selenium,而是通过 google_images_download 库。
    猜你喜欢
    • 1970-01-01
    • 2019-12-20
    • 2017-05-13
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多