簡體   English   中英

將 Chromedriver 與 Google 圖片一起使用 下載

[英]Using Chromedriver with Google Images download

我正在嘗試運行以下代碼來提取一些圖像:

from google_images_download import google_images_download   #importing the library

response = google_images_download.googleimagesdownload()   #class instantiation

arguments = {"keywords":"foxes, shiba inu outside","limit":2000,"print_urls":True}   #creating list of arguments
paths = response.download(arguments)   #passing the arguments to the function
print(paths)   #printing absolute paths of the downloaded images

因為我正在嘗試制作 100 多張圖片,所以我收到一條消息說

看起來我們無法找到“chromedriver”的路徑(使用“--chromedriver”參數指定可執行文件的路徑。)或您的計算機上未安裝 google chrome 瀏覽器(例外:預期的 str、bytes 或 os.PathLike object,不是無類型)

我不確定如何將 chromedriver 集成到我的代碼中並設置路徑。 我四處尋找,但找不到明確的答案。 我嘗試添加該行

browser = webdriver.Chrome(executable_path=r"/Users/jerelnovick/Desktop/Projects/Image_Recognition/chromedriver.exe")

正如我在一篇文章中所讀到的,但這給了我一條信息說

WebDriverException:消息:“Image_Recognitionchromedriver.exe”可執行文件需要在 PATH 中。 請參閱https://sites.google.com/a/chromium.org/chromedriver/home

我正在使用 Mac。

要獲得 100 多張圖像,還需要采取一些額外的步驟。 文檔

如果您想為每個關鍵字下載超過 100 張圖片,那么您需要安裝“selenium”庫以及“chromedriver”擴展程序。

然后您的arguments將需要更新為:

arguments = {"keywords":"foxes, shiba inu outside",
             "limit":2000,
             "print_urls":True,
             "chromedriver":"/Users/jerelnovick/Desktop/Projects/Image_Recognition/chromedriver"}

還要確保您下載的 chromedriver 是適用於 mac 的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM