How to Scrape Bing Images Results

Similar to Google Images Search, Bing Images Search is a service to help users find and explore visual content, including photographs, illustrations, graphics, logos, icons, and more.

Bing Images Search allows you to search by keywords, filter the results by size, color, type(photographs, clipart, line drawing...), people(just faces, head and shoulders), date(past 24 hours, past week...), and especially license(public domain, free to share and use....).

Whether you're a graphic designer, content creator, researcher, developer, or AI builder, scraping Bing Images results can provide you with thousands of images.

Let me show you a way to get all the images you need with a few lines of code, without any crawler libraries like Beautiful Soup(Python), playwright, cheerio...

With SerpApi, we provide RESTful APIs for you. Let's get started.

Setting up a SerpApi account

SerpApi offers a free plan for newly created accounts. Head to the sign-up page to register an account and complete your first search with our interactive playground. When you want to do more searches with us, please visit the pricing page.

Once you are familiar with all results, you can utilize SERP APIs using your API Key.

Scrape your first Bing Images results with SerpApi

Head to the Bing Images Results from the documentation on SerpApi for details.

In this tutorial, we will scrape top images when searching with "coffee" keyword. The data contains: "position", "title", "link", "size", "source", "description", "thumbnail", and more. You can also scrape more information with SerpApi.

First, you need to install the SerpApi client library.

pip install google-search-results

Set up the SerpApi credentials and search.

from serpapi import GoogleSearch
import os, json

params = {
    'api_key': 'YOUR_API_KEY',         # your serpapi api
    'engine': 'bing_images',           # SerpApi search engine	
    'q': 'coffee'
}

To retrieve Bing Images Results for a given search query, you can use the following code:

results = GoogleSearch(params).get_dict()['image_results']

You can store Bing Images Results JSON data in databases or export them to a CSV file.

import csv

header = ['position', 'title', 'link', 'size', 'source', 'description', 'thumbnail']

with open('bing_images.csv', 'w', encoding='UTF8', newline='') as f:
    writer = csv.writer(f)

    writer.writerow(header)

    for item in results:
        print(item)
        writer.writerow([item.get('position'), item.get('title'), item.get('link'), item.get('size'), item.get('source'), item.get('description'), item.get('thumbnail')])

This example is using Python, but you can also use your all your favorite programming languages likes Ruby, NodeJS, Java, PHP....

Want to scrape more images with Google Images? Check out this blog post.

If you have any questions, please feel free to contact me.