Package: bing-images
bing_imagesPython library to fetch image urls and download usingmultithreadingfromBing.com.FeaturesSupportfile typefilters.SupportBing.comfilteruifilters.Supportextra query params, such as&first=100&tsc=ImageBasicHoverinhttps://cn.bing.com/images/search?q=cat&first=100&tsc=ImageBasicHoverDownload usingmultithreadingand custom threadpool size.Supportpurelyobtaining the image urls.RequirementsChromedriverInstallGoogle Chrome Browser.Downloadchromedriverfromhere.Addchromedriverto PATH.Installationpipinstallbing-imagesUsageFetch Image Urlsfetch_image_urls.pyfrombing_imagesimportbingurls=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=1forurlinurls:print("{}:{}".format(counter,url))counter+=1Run❯ 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.pngfilters: You can visithttps://cn.bing.com/images/search?q=catto operate filters through the UI, and then observe the link changes.Download using multithreadingdownload.pyfrombing_imagesimportbingbing.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 isos.path.join(os.getcwd(), "bing-images")pool_size: thread poll sizeRun❯pythondownload.py
Savepath:/Users/catchzeng/Desktop/cat
Crawled70imageurls.
Downloadingimages#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 DownloadedRenamingimages
Finishedrenaming
Done
Elapsedtime:20.32sDownload images withfilteruifiltersdownload-square-and-black-white.pyfrombing_imagesimportbingbing.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)