9

I'm using google_images_download library to download top 20 images for a keyword. It's worked perfectly when I'm using it last days. Code is as follows.

from google_images_download import google_images_download

response = google_images_download.googleimagesdownload()

arguments = {"keywords":keyword,"limit":10,"print_urls":True}
paths = response.download(arguments)

Now it gives following error.

Evaluating...
Starting Download...


Unfortunately all 10 could not be downloaded because some images were not downloadable. 0 is all we got for this search filter!

Errors: 0

How can I solve this error.

eyllanesc
  • 190,383
  • 15
  • 87
  • 142
Amith
  • 579
  • 1
  • 10
  • 19

3 Answers3

12

There has been some changes on Google end (how they respond to the request) which results in this issue. Joeclinton1 on github has done some modifications to the original repo which provides a temporary fix.

You can find the updated repo here: https://github.com/Joeclinton1/google-images-download.git . The solution is in patch-1 branch if I'm not mistaken.

  1. First uninstall the current version of google_images_download.

  2. Then manually install Joeclinton1's repo by:

git clone https://github.com/Joeclinton1/google-images-download.git
cd google-images-download && sudo python setup.py install #no need for 'sudo' on windows Anaconda environment

or to install it with pip

pip install git+https://github.com/Joeclinton1/google-images-download.git

This should solve the problem. Note that currently this repo only supports upto 100 images.

Pradeep Singh
  • 309
  • 2
  • 10
Hiranya Jayakody
  • 380
  • 2
  • 12
  • If you have already installed google-images-download, you can use pip to uninstall the package. – Hiranya Jayakody May 05 '20 at 02:47
  • Ya @HiranyaJayakody, I later found that I didn't used pip to install the earlier repo, just used setup.py. I don't know how to undo that step, but pip installing Joeclinton1's repo on top just runs without any problem. Thanks. – Pradeep Singh May 05 '20 at 06:30
4

I faced the same issue with google-image-download, which used to work perfect earlier! I have an alternative that I would like to suggest, which should solve the problem.

Solution: Instead of using google-image-download for Python, use bing-image-downloader, that downloads from Bing! search engine.

Steps:

Step 1: Install the library by using: pip install bing-image-downloader

Step 2:

from bing_image_downloader import downloader
downloader.download(query_string, limit=100,  output_dir='dataset', 
adult_filter_off=True, force_replace=False, timeout=60)

That's it! All you would need to do is to add your image topic to the query_string.

Note:

Parameters that you can further tweak:

query_string : String to be searched.

limit : (optional, default is 100) Number of images to download.

output_dir : (optional, default is 'dataset') Name of output dir.

adult_filter_off : (optional, default is True) Enable of disable adult filteration.

force_replace : (optional, default is False) Delete folder if present and start a fresh download.

timeout : (optional, default is 60) timeout for connection in seconds.

Further Reference: https://pypi.org/project/bing-image-downloader/

Dharman
  • 21,838
  • 18
  • 57
  • 107
  • Yes, it's cool, but keep in mind that this does not solve the problem: bing-image-downloader often misses 100% of its results, or nearly 100%. It fails most of the time, and there's no indication as to why. – Wolfpack'08 Dec 10 '20 at 16:36
0

Another easy way to download any number of images :-

pip install simple_image_download

from simple_image_download import simple_image_download as simp

response = simp.simple_image_download response().download(a, b)

Where a= string of subject you want to download B= number of images you want to download

Thunder
  • 329
  • 1
  • 11