简体   繁体   English

从谷歌下载图片 图片搜索不起作用

[英]Download Images from google Image search not working

I'm trying to scrape images from google images using the google_images_download library by using it from another Python file.我正在尝试从另一个 Python 文件中使用 google_images_download 库从谷歌图像中抓取图像。 I previously used the code below about a month ago and it was fine but today morning it threw exception errors and then finally gave me the error大约一个月前我以前使用过下面的代码,它很好,但今天早上它抛出异常错误,然后最终给了我错误

Unfortunately all 100 could not be downloaded because some images were not downloadable不幸的是,由于某些图像无法下载,因此无法下载全部 100 张

I checked the documentation and GIT repo and noticed there were changes made 15 days ago, is there something I'm missing or is the library bugged?我检查了文档和 GIT 存储库并注意到 15 天前进行了更改,是我遗漏了什么还是库被窃听了? Also if there are better methods than this, kindly point me in the right direction.另外,如果有比这更好的方法,请指出我正确的方向。 My code is below:我的代码如下:

from google_images_download import google_images_download
response = google_images_download.googleimagesdownload()

arguments = {"keywords":"potato harvesting","limit":100,"format":"jpg","print_urls":True}
paths = response.download(arguments)

I figured a way to fix the error,through using the CLI instead of a Jupyter Notebook file.我想出了一种方法来修复错误,通过使用 CLI 而不是 Jupyter Notebook 文件。 I will list down the steps:我将列出步骤:

  1. First issue is probably how to uninstall the dependencies.第一个问题可能是如何卸载依赖项。 Since I used the python setup.py install , I manually had to uninstall them, luckily I found python setup.py uninstall and the procedure is layed out there on how to manually uninstall (highest voted answer).由于我使用了python setup.py install ,我必须手动卸载它们,幸运的是我找到了 python setup.py 卸载程序,其中列出了如何手动卸载的过程(最高投票的答案)。
  2. I then cloned the repo again in a new folder using :git clone https.//github.com/Joeclinton1/google-images-download.git via the CLI and then opened the files by cd google-images-download .然后,我通过 CLI 使用:git clone https.//github.com/Joeclinton1/google-images-download.git将 repo 再次克隆到一个新文件夹中,然后通过cd google-images-download打开文件。
  3. After,I reinstalled the packages using pip install.之后,我使用pip install. NOT python setup.py install .不是python setup.py install
  4. Use the CLI to download images by following the repo instructions in https://google-images-download.readthedocs.io/en/latest/examples.html .按照https://google-images-download.readthedocs.io/en/latest/examples.html中的 repo 说明使用 CLI 下载图像。

This worked for me and hopefully will work for you.这对我有用,希望对你有用。 Note: I cloned the repo in a new folder on the desktop for ease.注意:为方便起见,我将 repo 克隆到桌面上的一个新文件夹中。 The downloaded images will be in the same repo folder ie google-images-download under the Download file.下载的图像将位于同一 repo 文件夹中,即下载文件下的 google-images-download。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM