简体   繁体   中英

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. 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

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? 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. 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).
  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 .
  3. After,I reinstalled the packages using pip install. NOT 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 .

This worked for me and hopefully will work for you. Note: I cloned the repo in a new folder on the desktop for ease. The downloaded images will be in the same repo folder ie google-images-download under the Download file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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