Package: pygidl
Python Google Images DownloaderThis tool lets you download results from Google Images pretty fast. It usesaiohttpunder the hood. It is essentially
a Python 3.7 rewrite ofgoogle-images-downloaderwithout the restriction of not using external dependencies.InstallationThe following should work to install the utility and check that it will run:pipinstallpygidl
pygidl-hBasic UsageFrom the command line:basic usage is something likepygidl "cats and dogs". This will create an
output directory in your current working directory named for the timestamp that
the command was run. Underneath that directory will be another directory with
the slugified version of your query string. Underneath that directory will be
the downloaded images, named by their sha256 hashes and file type extensions:pygidl"cats and dogs"tree.
.
└──2020-01-21-17-57-34└──cats-and-dogs├──01d2dde343a45e3a1fcc5e7cd3cace33398c9b06a97e494d4329f264e57d5f57.jpg├──026cef34db26cbd5fa246bc720c1234b39ffa07737e43523b160390c13d5d3e6.jpeg├──03a0f2ebeed5d91acaed73ad303bd724767e101688e33d1a5557cca9139972d7.webp├──0affcf3198b40063e9302c4515380d6796946098c7c1c3c043072815e29e2770.jpeg...Advanced UsageThe command can be configured to support several more complex query scenarios:Verbose OutputUse the-v/--verboseflag to change the log level to show more messages. The
log level is "WARNING" by default. Supplying-vonce sets it to "INFO", and
two or more times sets it to "DEBUG".Prefixes and SuffixesThe-p/--prefixand-s/--suffixflags can be used to run multiple copies of
the same Google Images query with extra prefix or suffix strings. For example:pygidl-pAndorra-pAngola-s"on a ship"-s"on a plane"flag
tree-d.
.
└──2020-01-21-18-15-59├──andorra-flag-on-a-plane├──andorra-flag-on-a-ship├──angola-flag-on-a-plane└──angola-flag-on-a-ship5directoriesOutput GroupsYou can override the name of the directory that contains the results of each
query with the-g/--groupflag. For example:pygidl-g"Cute Animals"-pfluffy-padorable-sdog-scat""-v
tree.-d
.
└──cute-animals├──adorable-cat├──adorable-dog├──fluffy-cat└──fluffy-dog5directoriesFace SearchYou can tell Google Images to find faces with the-f/--faceflag. For example:pygidl-g"Tom Hanks"-p""-pyoung"Tom Hanks"-s""-s"Oscars"-f-v
tree-d.
.
└──tom-hanks├──tom-hanks├──tom-hanks-oscars├──young-tom-hanks└──young-tom-hanks-oscars5directoriesProgrammatic UsageSomething like the following should work (assuming you haveopencv-pythoninstalled in your environment):importasyncioimportosimportcv2frompygidlimportscrape_google_imagesdownloaded_image_paths=asyncio.run(scrape_google_images(base_query="cats and dogs",prefixes=["cute","adorable"],suffixes=["playing","running"],group="cute-animals",output_dir=os.getcwd(),face=False,))forpathindownloaded_image_paths:image=cv2.imread(path)ifimageisNone:print(f"could not load image{path}")continueheight,width=image.shape[:2]print(f"image{path}has size{width}x{height}")Known Issues and LimitationsOnly returns max of 100 results per queryDoesn't support full range of advanced search optionsNo testsNo retriesNo report on results/metadata output optionSometimes Google returns results from a different template without
easily-parseable metadataContributingI don't think anyone will ever get this far, but if you want to open a pull
request (or even better, take over ownership of the project for me!), go for it.
At a minimum, new code should have type hints, docstrings, and be auto-formatted
withblackwith an 80-character max line length. Even better would be some
tests and Sphinx documentation!