|
1 | 1 | # Better Bing Image Downloader
|
2 | 2 |
|
| 3 | +A powerful Python tool for downloading images from Bing and Google image search engines. |
| 4 | + |
| 5 | +[](https://github.com/KTS-o7/better_bing_image_downloader) |
| 6 | +[](https://github.com/KTS-o7/better-bing-image-downloader/blob/main/LICENSE) |
| 7 | +[](https://pypi.org/project/better-bing-image-downloader/) |
| 8 | +[](https://hits.seeyoufarm.com) |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- Download images from Bing and Google search engines |
| 13 | +- Parallel downloading for significantly faster performance |
| 14 | +- Multiple filtering options (image type, color, adult content, etc.) |
| 15 | +- Support for both API and browser-based image retrieval |
| 16 | +- Command-line interface and Python API |
| 17 | +- Multiple browser support (Firefox, Chrome, headless options) |
| 18 | +- Proxy support |
| 19 | + |
3 | 20 | ## Table of Contents
|
4 | 21 |
|
5 |
| -- [Disclaimer](#disclaimer) |
6 | 22 | - [Installation](#installation)
|
7 | 23 | - [Usage](#usage)
|
| 24 | + - [Python API](#python-api) |
| 25 | + - [Command Line Interface](#command-line-interface) |
| 26 | +- [Parameters](#parameters) |
| 27 | +- [Examples](#examples) |
8 | 28 | - [License](#license)
|
| 29 | +- [Disclaimer](#disclaimer) |
| 30 | +- [Changelog](#changelog) |
9 | 31 | - [Contact](#contact)
|
10 | 32 |
|
11 |
| -### Disclaimer<br /> |
| 33 | +## Installation |
12 | 34 |
|
13 |
| -This program lets you download tons of images from Bing. |
14 |
| -Please do not download or use any image that violates its copyright terms. |
| 35 | +### Using pip |
15 | 36 |
|
16 |
| - |
17 |
| - |
18 |
| -[](https://hits.seeyoufarm.com) |
| 37 | +```bash |
| 38 | +pip install better-bing-image-downloader |
| 39 | +``` |
19 | 40 |
|
20 |
| -### Installation <br /> |
| 41 | +### From source |
21 | 42 |
|
22 | 43 | ```bash
|
23 |
| -git clone https://github.com/KTS-o7better_bing_image_downloader |
24 |
| -python -m venv ./env |
25 |
| -source env/bin/activate |
| 44 | +git clone https://github.com/KTS-o7/better_bing_image_downloader |
26 | 45 | cd better_bing_image_downloader
|
| 46 | +python -m venv ./env |
| 47 | +source env/bin/activate # On Windows: env\Scripts\activate |
| 48 | +pip install -r requirements.txt |
27 | 49 | pip install .
|
28 | 50 | ```
|
29 | 51 |
|
30 |
| -or |
| 52 | +## Usage |
31 | 53 |
|
32 |
| -```bash |
33 |
| -pip install better-bing-image-downloader |
| 54 | +### Python API |
| 55 | + |
| 56 | +```python |
| 57 | +from better_bing_image_downloader import downloader |
| 58 | + |
| 59 | +# Basic usage |
| 60 | +downloader("cute puppies", limit=50) |
| 61 | + |
| 62 | +# Advanced usage |
| 63 | +downloader( |
| 64 | + query="cute puppies", |
| 65 | + limit=100, |
| 66 | + output_dir="my_images", |
| 67 | + adult_filter_off=True, |
| 68 | + force_replace=False, |
| 69 | + timeout=60, |
| 70 | + filter="photo", # Options: "line", "photo", "clipart", "gif", "transparent" |
| 71 | + verbose=True, |
| 72 | + badsites=["stock.adobe.com", "shutterstock.com"], |
| 73 | + name="Puppy", |
| 74 | + max_workers=8 # Parallel downloads |
| 75 | +) |
34 | 76 | ```
|
35 | 77 |
|
36 |
| -### PyPi <br /> |
| 78 | +### Command Line Interface |
37 | 79 |
|
38 |
| -[Package Link](https://pypi.org/project/better-bing-image-downloader/) |
| 80 | +The package provides two command-line interfaces: |
39 | 81 |
|
40 |
| -### Usage <br /> |
| 82 | +#### 1. Simple CLI (Bing-only) |
41 | 83 |
|
42 |
| -#### Using as a Package: |
| 84 | +```bash |
| 85 | +python -m better_bing_image_downloader.download "query" [options] |
| 86 | +``` |
43 | 87 |
|
44 |
| -```python |
45 |
| -from better_bing_image_downloader import downloader |
| 88 | +#### 2. Advanced CLI (Bing and Google) |
46 | 89 |
|
47 |
| -downloader(query_string, limit=100, output_dir='dataset', adult_filter_off=True, |
48 |
| -force_replace=False, timeout=60, filter="", verbose=True, badsites= [], name='Image') |
| 90 | +```bash |
| 91 | +python -m better_bing_image_downloader.multidownloader "query" [options] |
49 | 92 | ```
|
50 | 93 |
|
51 |
| -`query_string` : String to be searched.<br /> |
52 |
| -`limit` : (optional, default is 100) Number of images to download.<br /> |
53 |
| -`output_dir` : (optional, default is 'dataset') Name of output dir.<br /> |
54 |
| -`adult_filter_off` : (optional, default is True) Enable of disable adult filteration.<br /> |
55 |
| -`force_replace` : (optional, default is False) Delete folder if present and start a fresh download.<br /> |
56 |
| -`timeout` : (optional, default is 60) timeout for connection in seconds.<br /> |
57 |
| -`filter` : (optional, default is "") filter, choose from [line, photo, clipart, gif, transparent]<br /> |
58 |
| -`verbose` : (optional, default is True) Enable downloaded message.<br /> |
59 |
| -`bad-sites` : (optional, defualt is empty list) Can limit the query to not access the bad sites.<br/> |
60 |
| -`name` : (optional, default is 'Image') Can add a custom name for the images that are downloaded.<br/> |
| 94 | +## Parameters |
| 95 | + |
| 96 | +### Python API Parameters |
| 97 | + |
| 98 | +| Parameter | Type | Default | Description | |
| 99 | +| ---------------- | ---- | ---------- | ---------------------------------------------------------- | |
| 100 | +| query | str | (required) | Search term | |
| 101 | +| limit | int | 100 | Maximum number of images to download | |
| 102 | +| output_dir | str | 'dataset' | Directory to save images | |
| 103 | +| adult_filter_off | bool | True | Disable adult content filter | |
| 104 | +| force_replace | bool | False | Replace existing files and directories | |
| 105 | +| timeout | int | 60 | Connection timeout in seconds | |
| 106 | +| filter | str | "" | Image type filter (line, photo, clipart, gif, transparent) | |
| 107 | +| verbose | bool | True | Display detailed output | |
| 108 | +| badsites | list | [] | List of sites to exclude from results | |
| 109 | +| name | str | 'Image' | Base name for downloaded images | |
| 110 | +| max_workers | int | 4 | Number of parallel download threads | |
| 111 | + |
| 112 | +### Command Line Arguments (multidownloader.py) |
| 113 | + |
| 114 | +| Argument | Short | Default | Description | |
| 115 | +| -------------- | ----- | ------------------- | ---------------------------------------------------- | |
| 116 | +| --engine | -e | "Bing" | Search engine ("Google" or "Bing") | |
| 117 | +| --driver | -d | "firefox_headless" | Browser driver to use | |
| 118 | +| --max-number | -n | 100 | Maximum number of images to download | |
| 119 | +| --num-threads | -j | 50 | Number of concurrent download threads | |
| 120 | +| --timeout | -t | 10 | Download timeout in seconds | |
| 121 | +| --output | -o | "./download_images" | Output directory | |
| 122 | +| --safe-mode | -S | False | Enable safe search mode | |
| 123 | +| --face-only | -F | False | Only search for faces | |
| 124 | +| --proxy_http | -ph | None | HTTP proxy address (e.g., 192.168.0.2:8080) | |
| 125 | +| --proxy_socks5 | -ps | None | SOCKS5 proxy address (e.g., 192.168.0.2:1080) | |
| 126 | +| --type | -ty | None | Image type filter (clipart, linedrawing, photograph) | |
| 127 | +| --color | -cl | None | Color filter for images | |
| 128 | + |
| 129 | +## Examples |
| 130 | + |
| 131 | +### Basic Search |
61 | 132 |
|
62 |
| -#### Using as a Command Line Tool: |
| 133 | +```python |
| 134 | +from better_bing_image_downloader import downloader |
63 | 135 |
|
64 |
| -```bash |
65 |
| - git clone https://github.com/KTS-o7/better_bing_image_downloader.git |
66 |
| - cd better_bing_image_downloader |
67 |
| - python -m venv ./env |
68 |
| - source env/bin/activate |
69 |
| - pip install -r requirements.txt |
70 |
| - cd better_bing_image_downloader |
71 |
| - # This is an example query |
72 |
| - python multidownloader.py "cool doggos" --engine "Bing" --max-number 50 --num-threads 5 --driver "firefox_headless" |
| 136 | +# Download 100 cat images to ./dataset/cats |
| 137 | +downloader("cats", limit=100) |
73 | 138 | ```
|
74 | 139 |
|
75 |
| -#### Command Line Arguments: |
| 140 | +### Advanced Search with Filters |
76 | 141 |
|
77 |
| -```bash |
78 |
| -multidownloader.py "keywords" [-h] [--engine {Google,Bing}] [--driver {chrome_headless,chrome,api,firefox,firefox_headless}] [--max-number MAX_NUMBER] [--num-threads NUM_THREADS] [--timeout TIMEOUT] [--output OUTPUT] [--safe-mode] [--face-only] [--proxy_http PROXY_HTTP] [--proxy_socks5 PROXY_SOCKS5] [--type {clipart,linedrawing,photograph}] [--color COLOR] |
| 142 | +```python |
| 143 | +# Download 50 transparent clipart images with parallel processing |
| 144 | +downloader( |
| 145 | + query="logo design", |
| 146 | + limit=50, |
| 147 | + filter="transparent", |
| 148 | + max_workers=8, |
| 149 | + output_dir="logos" |
| 150 | +) |
79 | 151 | ```
|
80 | 152 |
|
81 |
| -- `"keywords"`: Keywords to search. ("in quotes") |
82 |
| -- `-h, --help`: Show the help message and exit |
83 |
| -- `--engine, -e`: Image search engine. Choices are "Google" and "Bing". Default is "Bing". |
84 |
| -- `--driver, -d`: Image search engine. Choices are "chrome_headless", "chrome", "api", "firefox", "firefox_headless". Default is "firefox_headless". |
85 |
| -- `--max-number, -n`: Max number of images download for the keywords. Default is 100. |
86 |
| -- `--num-threads, -j`: Number of threads to concurrently download images. Default is 50. |
87 |
| -- `--timeout, -t`: Seconds to timeout when download an image. Default is 10. |
88 |
| -- `--output, -o`: Output directory to save downloaded images. Default is "./download_images". |
89 |
| -- `--safe-mode, -S`: Turn on safe search mode. (Only effective in Google) |
90 |
| -- `--face-only, -`F: Only search for faces. |
91 |
| -- `--proxy_http, -ph`: Set http proxy (e.g. 192.168.0.2:8080) |
92 |
| -- `--proxy_socks5, -ps`: Set socks5 proxy (e.g. 192.168.0.2:1080) |
93 |
| -- -`-type, -ty`: What kinds of images to download. Choices are "clipart", "linedrawing", "photograph". |
94 |
| -- `--color, -cl`: Specify the color of desired images. |
| 153 | +### Command Line Usage |
95 | 154 |
|
96 | 155 | ```bash
|
97 |
| -# Example usage |
98 |
| -python multidownloader.py "Cool Doggos" --engine "Google" --driver "chrome_headless" --max-number 50 --num-threads 10 --timeout 60 --output "./doggo_images" --safe-mode --proxy_http "192.168.0.2:8080" --type "photograph" --color "blue" |
| 156 | +# Download 50 landscape photographs using Google |
| 157 | +python -m better_bing_image_downloader.multidownloader "mountain landscape" --engine "Google" --max-number 50 --type "photograph" |
| 158 | + |
| 159 | +# Download 100 cat images using Bing with Firefox headless |
| 160 | +python -m better_bing_image_downloader.multidownloader "cats" --engine "Bing" --driver "firefox_headless" --max-number 100 |
99 | 161 | ```
|
100 | 162 |
|
101 |
| ---- |
| 163 | +## Disclaimer |
102 | 164 |
|
103 |
| -## Star History |
| 165 | +This program lets you download images from search engines. Please do not download or use any image that violates its copyright terms. The developers of this tool are not responsible for any misuse. |
104 | 166 |
|
105 |
| -[](https://www.star-history.com/#KTS-o7/better-bing-image-downloader&Date) |
| 167 | +## Changelog |
| 168 | + |
| 169 | +### 2.0.0 |
| 170 | + |
| 171 | +- Added parallel downloading for significantly faster image retrieval |
| 172 | +- Improved error handling and recovery |
| 173 | +- Better memory management and code organization |
| 174 | +- Fixed progress bar display issues |
| 175 | +- Added max_workers parameter to control parallel downloads |
| 176 | +- Added new requirements |
106 | 177 |
|
107 |
| -### License |
| 178 | +### 1.1.3 |
108 | 179 |
|
109 |
| -This project is licensed under the terms of the MIT license. |
| 180 | +- Fixed issue with invalid image types |
| 181 | +- Replaced imghdr with filetype for more reliable image type detection |
110 | 182 |
|
111 |
| -### Contact |
| 183 | +## License |
112 | 184 |
|
113 |
| -If you have any questions or feedback, please contact us at [email](mailto:shentharkrishnatejaswi@gmail.com). |
| 185 | +This project is licensed under the MIT License - see the LICENSE file for details. |
114 | 186 |
|
115 |
| -### Changelog |
| 187 | +## Contact |
116 | 188 |
|
117 |
| -- 1.1.3: |
118 |
| - - Fixed issue with invalid image types. Deleted imghdr and used filetype to check image types. |
| 189 | +If you have any questions or feedback, please contact the developer at [shentharkrishnatejaswi@gmail.com](mailto:shentharkrishnatejaswi@gmail.com). |
| 190 | + |
| 191 | +## Star History |
| 192 | + |
| 193 | +[](https://www.star-history.com/#KTS-o7/better-bing-image-downloader&Date) |
0 commit comments