hardikvasa / google-images-download

Python Script to download hundreds of images from 'Google Images'. It is a ready-to-run code!
MIT License
8.57k stars 2.11k forks source link

TypeError: 'NoneType' object is not subscriptable #356

Open rafarios opened 3 years ago

rafarios commented 3 years ago

Hi. Using 2.8.0, It was working properly yesterday, buy today I receive this error. Can you review it?

Traceback (most recent call last): File "/usr/local/bin/googleimagesdownload", line 11, in load_entry_point('google-images-download==2.8.0', 'console_scripts', 'googleimagesdownload')() File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 1134, in main File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 952, in download File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 1087, in download_executor File "/usr/local/lib/python3.7/dist-packages/google_images_download-2.8.0-py3.7.egg/google_images_download/google_images_download.py", line 888, in _get_all_items TypeError: 'NoneType' object is not subscriptable

NicolasGrosjean commented 3 years ago

Hi @rafarios,

Have you the same issue with the Joeclinton1 version which is more up to date ?

You can install it with

git clone https://github.com/Joeclinton1/google-images-download.git
cd google-images-download && python setup.py install
is0356xi commented 3 years ago

'183836587' is no longer included in 'image_object'. In my case, I commented out line 391 of google_images_download.py and now I can run it.

def format_object(self, object):
        data = object[1]
        main = data[3]
        info = data[9]
        if info is None:
            info = data[11]
        formatted_object = {}
        try:
            formatted_object['image_height'] = main[2]
            formatted_object['image_width'] = main[1]
            formatted_object['image_link'] = main[0]
            formatted_object['image_format'] = main[0][-1 * (len(main[0]) - main[0].rfind(".") - 1):]
            formatted_object['image_description'] = info['2003'][3]
            # formatted_object['image_host'] = info['183836587'][0]
            formatted_object['image_source'] = info['2003'][2]
            formatted_object['image_thumbnail_url'] = data[2][0]
        except Exception as e:
            print(e)
            return None

        return formatted_object
rafarios commented 3 years ago

Thanks @is0356xi

Now it works!

Joeclinton1 commented 3 years ago

I implemented a fix in the most recent commit by changing the location of image_host. Should work now :)

moisty70 commented 1 year ago

I cannot get it to work:

Item no.: 1 --> Item name = Polar bears Evaluating... Starting Download... 'NoneType' object is not subscriptable Traceback (most recent call last): File "/cygdrive/d/dev/git/pythonaf/testGDI.py", line 6, in paths = response.download(arguments) #passing the arguments to the function File "/usr/lib/python3.9/site-packages/google_images_download-2.8.0-py3.9.egg/google_images_download/google_images_download.py", line 970, in download File "/usr/lib/python3.9/site-packages/google_images_download-2.8.0-py3.9.egg/google_images_download/google_images_download.py", line 1118, in download_executor File "/usr/lib/python3.9/site-packages/google_images_download-2.8.0-py3.9.egg/google_images_download/google_images_download.py", line 906, in _get_all_items TypeError: 'NoneType' object is not subscriptable

testGDI.py is:

from google_images_download import google_images_download #importing the library

response = google_images_download.googleimagesdownload() #class instantiation

arguments = {"keywords":"Polar bears,baloons,Beaches","limit":20,"print_urls":True} #creating list of arguments paths = response.download(arguments) #passing the arguments to the function