Code Monkey home page Code Monkey logo

google-images-download's Introduction

Google Images Download

Python Script for 'searching' and 'downloading' hundreds of Google images to the local hard disk!

Documentation

Disclaimer

This program lets you download tons of images from Google. Please do not download or use any image that violates its copyright terms. Google Images is a search engine that merely indexes images and allows you to find them. It does NOT produce its own images and, as such, it doesn't own copyright on any of them. The original creators of the images own the copyrights.

Images published in the United States are automatically copyrighted by their owners, even if they do not explicitly carry a copyright warning. You may not reproduce copyright images without their owner'self permission, except in "fair use" cases, or you could risk running into lawyer'self warnings, cease-and-desist letters, and copyright suits. Please be very careful before its usage! Use this script/code only for educational purposes.

google-images-download's People

Contributors

a0m0rajab avatar adayton1 avatar antetokounpo avatar anumpatel avatar auromun avatar boxabirds avatar cedric-garcia avatar crainbows avatar cslite avatar ellisbrown avatar estuhr1206 avatar freddierice avatar hardikvasa avatar harniva14 avatar hellogan avatar jithinjk avatar joeclinton1 avatar leemengtw avatar lflyou1314 avatar matthewlehew avatar mentatpsi avatar nicolasgrosjean avatar norihito-t avatar noskillguy avatar psuzn avatar rachmadaniharyono avatar successren avatar tranquilled avatar voins avatar voronaam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

google-images-download's Issues

Missing Error Handling for Limit equal or less than 0 when executed using from another Python file

Heyy, I've used this lib for a personal proejct and now I'm using it for a college course on Software Testing, applying some tests I identified the following problem in error handling

Issue description

When the limit argument (optional) is set to zero or below the lib download the 100 default image without any warning or exception
because of the invalid parameter passed

Steps to reproduce the issue

1. Clone repository
**2. **cd google-images-download && sudo python setup.py install
3. In this respository create a python script
4. Import from google_images_download import google_images_download
5. Add the following commands

response = google_images_download.googleimagesdownload() 
arguments = {'keywords': 'dog', 'limit': 0}
response.download(arguments)

6. Run script

What's the expected result?

  • Some error message to explicit that is not possible to download 0 images

What's the actual result?

  • It downloads all default 100 images

Additional details / screenshot

image

Missing Error handling for when the offset is above the limit passed when running from another Python file

Heyy, I've used this lib for a personal proejct and now I'm using it for a college course on Software Testing, applying some tests I identified the following problem in error handling

Issue description

When the offset argument (optional) is above the limit parameter the lib download images without any warning or exception

Steps to reproduce the issue

1. Clone repository
**2. **cd google-images-download && sudo python setup.py install
3. In this respository create a python script
4. Import from google_images_download import google_images_download
5. Add the following commands

response = google_images_download.googleimagesdownload() 
arguments = {'keywords': 'dog', 'limit': 5, 'offset': 9}
response.download(arguments)

6. Run script

What's the expected result?

  • Some error message to explicit that is not possible to have an offset above the limit

What's the actual result?

  • It downloads 0 images

Additional details / screenshot

image

ChromeDriver Fix (WebDriver object has no attribute 'find_element_by*')

To fix the use of ChromeDriver (to allow 100+ image downloads)..
(These can be found around line 321+ depending on existing previous mods):

#browser.find_element_by_css_selector("[aria-label='Accept all']").click()
browser.find_element(By.CSS_SELECTOR, "[aria-label='Accept all']").click()
#element = browser.find_element_by_tag_name("body")
element = browser.find_element(By.TAG_NAME, "body")
#browser.find_element_by_xpath('//input[@value="Show more results"]').click()
browser.find_element(By.XPATH, '//input[@value="Show more results"]').click()

This might be related to: #25 #30 #31 #37

Image objects data unpacking failed. Please leave comment...

The error occurs because Google Images itself returns zero images. "Looks like there aren’t any matches for your search."
Everything else works fine, but this has a sys.exit() (Line 251), and even if I remove that, it will still come back with an unpacking error at a different point.
I clumsily tried to manually add new arguments(i.e. a query that Google definitely has images for e.g. Bugs Bunny) at this point(Line 252) but...trying to fix one problem creates three more.

Image objects data unpacking

Item no.: 1 --> Item name = coolman
Evaluating...
Expecting value: line 1 column 1 (char 0)
Image objects data unpacking failed. Please leave a comment with the above error at https://github.com/Joeclinton1/google-images-download/pull/26

Got this error, codes pretty simple. Can't find a fix though I'm sure there's a simple one. My code is below

from google_images_download import google_images_download

response = google_images_download.googleimagesdownload()
keyword = "coolman"
arguments = {"keywords":response,"limit":5,"print_urls":True}
paths = response.download(arguments)

Can not download more than 98 images with chromedriver

Hi all, unfortunately I can't download more than 98 images with chromedriver. I get this error message:

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

Errors: 2


Everything downloaded!

I have entered the following command:

googleimagesdownload --keywords "nature" --limit 350 --chromedriver "google-images-download/chromedriver"

I also tried with selenium 4.4.3. But unfortunately the same error appears. However, I had to make some adjustments with the newer selenium, because find_element_by_xpath, find_element_by_tag_name and find_element_by_css_selector are deprecated according to the doc.

Does anyone have an idea how I can download more than 97 images?

Could not open URL

Hi all, I have installed the package with:

python setup.py build
python setup.py install

Unfortunately I get the message:

googleimagesdownload --keywords "Polar bears, baloons, Beaches" --limit 20


Item no.: 1 --> Item name = Polar bears
Evaluating...
Could not open URL. Please check your internet connection and/or ssl settings 
If you are using proxy, make sure your proxy settings is configured correctly

Did anyone also get this message? Is there a solution for this?

I do not use a proxy and an Internet connection is available

I just created a python environment and installed the google-images-download package with certifi.

System is macOS Catalina
Python 3.9

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Hi @Joeclinton1, Thanks for keeping the repo alive :)
Im trying to download 500 images but getting the following error:

Traceback (most recent call last):
  File "/home/Documents/google-images-download/download_google_images.py", line 6, in <module>
    paths = response.download(arguments)   #passing the arguments to the function
  File "/home/Documents/google-images-download/google_images_download/google_images_download.py", line 946, in download
    paths, errors = self.download_executor(arguments)
  File "/home/Documents/google-images-download/google_images_download/google_images_download.py", line 1085, in download_executor
    images, tabs = self.download_extended_page(url, arguments['chromedriver'])
  File "/home/Documents/google-images-download/google_images_download/google_images_download.py", line 313, in download_extended_page
    images = self._image_objects_from_pack(self._extract_data_pack_extended(source))
  File "/home/Documents/google-images-download/google_images_download/google_images_download.py", line 199, in _image_objects_from_pack
    image_objects = json.loads(data)[31][-1][12][2]
  File "/home/anaconda3/envs/analytics/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/home/anaconda3/envs/analytics/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/anaconda3/envs/analytics/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I tried your fork as well but no success. Do you have any idea how can I solve it?

Thanks!!

Error when running...

Getting an error with every try, for example:...

googleimagesdownload --keywords "ty cobb" --limit 10
Item no.: 1 --> Item name = ty cobb
Evaluating...
str() takes at most 1 argument (2 given)
Image objects data unpacking failed. Please leave ...

Python 2.7.17
Ubuntu 18.04.4 LTS
Selenium 3.141.0

Missing Error handling for delay below 0 when running lib from another Python file

Heyy, I've used this lib for a personal proejct and now I'm using it for a college course on Software Testing, applying some tests I identified the following problem in error handling

Issue description

When the delay argument (optional) is below the lib images without any warning or exception

Steps to reproduce the issue

1. Clone repository
**2. **cd google-images-download && sudo python setup.py install
3. In this respository create a python script
4. Import from google_images_download import google_images_download
5. Add the following commands

response = google_images_download.googleimagesdownload() 
arguments = {'keywords': 'dog', 'limit': 5, 'delay': -0.1}
response.download(arguments)

6. Run script

What's the expected result?

  • Some error message to explicit that is not possible to download images with negative delay interval

What's the actual result?

  • It downloads the expected number of images

Additional details / screenshot

image

"Some images not downloadable"

"Some images not downloadable" but none of the images were downloaded.

$ googleimagesdownload --keywords "boxes" -l 10

Item no.: 1 --> Item name = boxes
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


Everything downloaded!
Total errors: 0
Total time taken: 0.8608839511871338 Seconds

exact_size does not work.

I entered the following command but the images with different sizes were downloaded.

python google_images_download.py --keywords "baloons" --exact_size 1920,1080 --limit 5

Missing Error handling for when the offset is negative when using in another Python File

Heyy, I've used this lib for a personal proejct and now I'm using it for a college course on Software Testing, applying some tests I identified the following problem in error handling

Issue description

When the offset argument (optional) is below zero the lib download images without any warning or exception

Steps to reproduce the issue

1. Clone repository
**2. **cd google-images-download && sudo python setup.py install
3. In this respository create a python script
4. Import from google_images_download import google_images_download
5. Add the following commands

response = google_images_download.googleimagesdownload() 
arguments = {'keywords': 'dog', 'limit': 5, 'offset': -9}
response.download(arguments)

6. Run script

What's the expected result?

  • Some error message to explicit that is not possible to have a negative offset

What's the actual result?

  • It downloads the expected number of images without any error message

Additional details / screenshot

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.