bing_images
Python library to fetch image urls and download using multithreading from Bing.com.
Features
- Support file type filters.
- Support Bing.com filterui filters.
- Support extra query params, such as
&first=100&tsc=ImageBasicHoverinhttps://cn.bing.com/images/search?q=cat&first=100&tsc=ImageBasicHover - Download using multithreading and custom thread pool size.
- Support purely obtaining the image urls.
Requirements
Chromedriver
- Install Google Chrome Browser.
- Download
chromedriverfrom here. - Add
chromedriverto PATH.
Installation
pip install bing-images
Usage
Fetch Image Urls
fetch_image_urls.py
from bing_images import bing
urls = bing.fetch_image_urls("cat", limit=10, file_type='png', filters='+filterui:aspect-square+filterui:color2-bw', extra_query_params='&first=1')
print("{} images.".format(len(urls)))
counter = 1
for url in urls:
print("{}: {}".format(counter, url))
counter += 1
Run
❯ python fetch_image_urls.py
Crawled 70 image urls.
10 images.
1: http://www.freeiconspng.com/uploads/cat-png-9.png
2: http://pngimg.com/uploads/cat/cat_PNG1616.png
3: https://pngimg.com/uploads/cat/cat_PNG1621.png
4: https://pngimg.com/uploads/cat/cat_PNG50532.png
5: http://pngimg.com/uploads/cat/cat_PNG50501.png
6: http://www.pngmart.com/files/5/Black-Cat-PNG-Transparent.png
7: https://pngimg.com/uploads/cat/cat_PNG1618.png
8: http://pngimg.com/uploads/cat/cat_PNG1624.png
9: http://assets.stickpng.com/thumbs/580b57fbd9996e24bc43bb8a.png
10: https://www.freeiconspng.com/uploads/black-cat-png-4.png
filters: You can visit https://cn.bing.com/images/search?q=cat to operate filters through the UI, and then observe the link changes.
Download using multithreading
download.py
from bing_images import bing
bing.download_images("cat",
20,
output_dir="/Users/catchzeng/Desktop/cat",
pool_size=10,
file_type="png",
force_replace=True,
extra_query_params='&first=1')
- output_dir: the default output_dir is
os.path.join(os.getcwd(), "bing-images")- pool_size: thread poll size
Run
❯ python download.py
Save path: /Users/catchzeng/Desktop/cat
Crawled 70 image urls.
Downloading images
#1 http://pngimg.com/uploads/cat/cat_PNG50509.png Downloaded
#2 https://pngimg.com/uploads/cat/cat_PNG50498.png Downloaded
#3 http://pngimg.com/uploads/cat/cat_PNG106.png Downloaded
#4 http://pluspng.com/img-png/png-cute-cat-ginger-cat-1280.png Downloaded
#5 http://www.freepngimg.com/download/cat/22193-3-adorable-cat.png Downloaded
#6 http://pngimg.com/uploads/cat/cat_PNG50440.png Downloaded
#7 http://pngimg.com/uploads/cat/cat_PNG50514.png Downloaded
#8 https://pngimg.com/uploads/cat/cat_PNG50482.png Downloaded
#9 https://pngimg.com/uploads/cat/cat_PNG50480.png Downloaded
#10 https://pngimg.com/uploads/cat/cat_PNG50479.png Downloaded
#11 http://pngimg.com/uploads/cat/cat_PNG50442.png Downloaded
#12 https://pngimg.com/uploads/cat/cat_PNG50447.png Downloaded
#13 https://pngimg.com/uploads/cat/cat_PNG50512.png Downloaded
#14 https://pngimg.com/uploads/cat/cat_PNG50456.png Downloaded
#15 https://pngimg.com/uploads/cat/cat_PNG50465.png Downloaded
#16 http://pngimg.com/uploads/cat/cat_PNG50529.png Downloaded
#17 http://pngimg.com/uploads/cat/cat_PNG50433.png Downloaded
#18 http://pngimg.com/uploads/cat/cat_PNG50434.png Downloaded
#19 http://pngimg.com/uploads/cat/cat_PNG50416.png Downloaded
#20 https://purepng.com/public/uploads/large/purepng.com-catanimalscat-981524673949tj5ns.png Downloaded
Renaming images
Finished renaming
Done
Elapsed time: 20.32s
Download images with filterui filters
download-square-and-black-white.py
from bing_images import bing
bing.download_images("cat",
20,
output_dir="/Users/catchzeng/Desktop/cat",
pool_size=20,
file_type="png",
filters='+filterui:aspect-square+filterui:color2-bw',
force_replace=True)
Metadata
Release files for bing-images 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bing_images-0.2.3.tar.gz | 6.2 kB | Without provenance | Details for bing_images-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bing_images-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for bing_images-0.2.3-py3-none-any.whl |
Total release size: 13.3 kB
Release files / bing_images-0.2.3.tar.gz
| Download URL | bing_images-0.2.3.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36ccb277aa5dd9229a27471ec807c0bab0c1094036bfd206119719d1b50e1951
|
|
BLAKE2b-256 checksum How to use checksums |
4fb3373aa17a3560a9bc609fa843b19a68d37ac566703d0bfc3825db31135bf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Release files / bing_images-0.2.3-py3-none-any.whl
| Download URL | bing_images-0.2.3-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
632c02a63c39732295e035a3d300f1d635bfe00a37ca74c39db1a7788f6d70bd
|
|
BLAKE2b-256 checksum How to use checksums |
da0979bab6ae8b42860c5bcefb32211b66ad706f3c7d92a65911dc8765410506
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Security for bing-images 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.