Python module for searching and downloading images from Ecosia
Project description
python-ecosia-images
Python module for searching and downloading images from Ecosia
Installing
pip install ecosia-images
Setup
The only requisite to work with the library is to have a chromedriver executable in the PATH. See the following link for more information.
Examples
Search images and get the links to the pictures
After declaring a crawler and using it to search for a keyword, the resulting links will be accesible by the links
property
>>> from ecosia_images import crawler
>>> searcher = crawler()
>>> searcher.search('number 9')
>>> searcher.links
{ ... } # urls
Gather more links
If more links are needed the function gather_more
can be used.
>>> searcher.search('bees')
>>> len(searcher.links)
50 # Give or take
>>> searcher.gather_more()
100 # Give or take
Download images
In all the following cases, the script first checks whether the image has been already downloaded so it does not downloads it again. Also, the functions will return the file paths to the downloaded images.
The download
function will download a given number of pictures and save them in a folder whose name coincides with the keyword. This folder will be created inside the one specified when calling the function. In the following example, the images would be saved inside /path/to/folder/keyword/.
>>> searcher.search('keyword')
>>> searcher.download(100, '/path/to/folder/')
[ ... ] # list with file paths
If no folder is specified, the images will be saved inside a new folder named downloads located in the current working directory.
>>> searcher.search('apples')
>>> searcher.download(100) # The pictures will be saved at ./downloads/apples/
[ ... ]
There is also the download_all
function which will download all the currently available links in the crawler object
>>> searcher.search('pidgeons')
>>> searcher.download_all()
[ ... ]
Stoping the client
It is necessary to stop the crawler to avoid resource leak.
>>> searcher.stop()
Disclaimer
The images come from the Ecosia search engine. They may have copyrights and the original creators own these. Do not download or use any image that violates its copyright terms.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ecosia_images-0.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9818df6429b9e03f6fc6d0be224767097ba67e87618d6266b2aa2d51701a95b1 |
|
MD5 | a09dbff369b643044268e8f048afb39c |
|
BLAKE2b-256 | 4b0f7f036a117ca497950b3fa427d1f80e09d03d17be086621c4f65bf95d5973 |