How to fix issue with script that uses google_images_download library - issues likely related to internet / ssl / proxy?

Viewed 3803

I wrote a python script that called upon google_images_download library in order to scrape images from google using a command line tool.

On my computer, the code runs and downloads the images, but when I use another computer with the same script it provides the error in the title.

I have ensured the libraries are installed and that the other computers have Python 3.

I tried using different wifi networks to see if that would fix the issue. On two separate other laptops other than mine I got the same error.

from google_images_download import google_images_download
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("query")
parser.add_argument("limit", type=int)
args = parser.parse_args()


def download_images(query, limit):
    response = google_images_download.googleimagesdownload()
    arguments = {"keywords": query,
                 "limit": limit}
    try:
        response.download(arguments)


    except FileNotFoundError:
        arguments = {"keywords": query,
                     "limit": limit}

        try:
            response.download(arguments)
        except:
            pass




def main(query, limit):
    download_images(query, limit)
    print("Images Printed")

if __name__ == '__main__':
    main(args.query, args.limit)

I expected the output to create a folder called downloads with a sub folder that is the name of the query and place a specified number of images in the sub folder.

In the terminal it should say downloading Image I through N.

The output is the error code shown in the title:

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

This fixed it. It was a certificate issue

cd /Applications/Python\ 3.7/
./Install\ Certificates.command
Related