![](/img/trans.png)
[英]Python Selenium download images (jpeg, png) or PDF using ChromeDriver
[英]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.