Logo

dev-resources.site

for different kinds of informations.

Bulk Image Search with Google Lens

Published at
11/12/2024
Categories
webscraping
googlelens
serpapi
Author
nate_serpapi
Categories
3 categories in total
webscraping
open
googlelens
open
serpapi
open
Author
12 person written this
nate_serpapi
open
Bulk Image Search with Google Lens

Bulk Image Search: Getting Started

Introducing the Bulk Image Search tool - a simple, no-code web app to utilize SerpApi's Google Lens API. Whether you're a researcher, marketer, or someone who performs many visual searches, the Bulk Image Search tool streamlines visual searches and helps you get the insights you need faster. Keep reading to learn how to get started.

What Does It Do?

  • Upload images to Imgur in bulk
  • Scrape multiple Google Lens search results simultaneously
  • Download search results in your preferred format (CSV, JSON, or Excel)
  • Access images from your Imgur account

SerpApi Introduction

SerpApi is a web scraping company that allows developers to extract search engine results and data from various search engines, including Google, Bing, Yahoo, Baidu, Yandex, and others. It provides a simple way to access search engine data programmatically without dealing directly with the complexities of web scraping.

Google Lens API

This tool uses SerpApi's Google Lens API to scrape search results from Google Lens search results (https://lens.google/) when performing an image search. The results related to the image could contain visual matches, video, text, and other data. Search results can be returned from specific countries or languages.

The Google Lens API currently only supports images with URLs, meaning the image must be hosted publicly to be searched. SerpApi has an open feature request to enable file uploads, and you can follow on it's progress here:

[Google Lens API] Support image search via file upload #948

To-do

  • [ ] Implement Google Lens and Reverse Image search via file upload
  • [ ] Document that async=1 is not available for these requests

Experimental implementation: https://github.com/serpapi/SerpApi/pull/2412

Use Cases

The Google Lens API can be leveraged for various use cases across different industries. Here are a few examples:

Visual Search for E-commerce

  • Identify similar products or alternatives based on an image of a product
  • Monitor competitor pricing and product offerings by searching for their images

Academic and Scientific Research

  • Identify plant and animal species from images
  • Reverse image search to find the original source of an image
  • Find similar images for training AI models

Trend Analysis

  • Detect emerging visual styles, designs, or themes across industries
  • Monitor changes in product packaging, advertising, or website designs over time
  • Gather insights on popular visual motifs, objects, or scenes

The Google Lens API is a versatile and powerful tool for developers, researchers, marketers, and anyone who needs to extract insights from visual data at scale. By leveraging programmatic access to this visual search functionality, users can streamline their workflows.

You can test the Google Lens API in SerpApi's playground environment found here:

SerpApi Playground

Quick Setup

1 - Sign up for free accounts:

  • An Imgur account, for storing your images.
  • A SerpApi account, is needed to perform searches. SerpApi provides a free plan with 100 successful searches included every month.

2 - Log in to Bulk Image Search with your Imgur account

Log in

3 - Add your SerpApi API key to the settings page.

Save SerpApi Key

Using the Tool

In this section, we will walk through performing a bulk image search. The tool has three simple steps: uploading your images, configuring your search parameters, and reviewing your results.

Upload Images

Head to the upload page page to get started. You can upload up to 50 images with a maximum single image size of 4.5MB:

https://bulkimagesearch.com/upload

Upload image

Search Images

After adding images to your Imgur account, navigate to the search page to select all the images you would like to search for, set your search parameters, and choose the format you want the results returned in.

Search page

Get Your Results

Click the "Search" button to start your search. Before your searches are processed, you'll be asked to confirm the maximum number of credits that will be used.

Search Confirmation

Note that if you perform a search with the same parameters within an hour, SerpApi will serve cached results that do not count against your monthly search quota. To bypass search caching, select the "No Cache" search option.

Search Results

Manual Method

Now that I've shown you how easy it is to use the Bulk Image Search tool let's discuss what it would take to accomplish this manually using scripts (or as close as possible).

Image Hosting

One common issue I see while trying to use the Google Lens API is searching for images hosted via AWS S3 buckets. For whatever reason, Google Lens has trouble processing AWS URLs, making choosing an image hosting option a bit tricky.

For this reason, I typically suggest users host their images on Imgur (https://imgur.com/), as the issues mentioned above do not exist for Imgur URLs.

Imgur uses OAuth 2.0 for Authorization of requests; while I won't walk through the complete configuration, below are some resources for getting up and running with the Imgur API:

Image Uploading

Once Authorization is set up, uploading images to Imgur is as easy as POSTing form data to the following endpoint:

https://api.imgur.com/3/image

Below is an example from Imgur's docs from uploading an image:

var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://api.imgur.com/3/image',
  'headers': {
    'Authorization': 'Client-ID {{clientId}}'
  },
  formData: {
    'image': {
      'value': fs.createReadStream('/home/flakrim/Downloads/GHJQTpX.jpeg'),
      'options': {
        'filename': 'GHJQTpX.jpeg',
        'contentType': null
      }
    },
    'type': 'image',
    'title': 'Simple upload',
    'description': 'This is a simple image upload in Imgur'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Enter fullscreen mode Exit fullscreen mode

Image Search

After uploading your images to Imgur and storing the image's URL, you can start fetching search results from the Google Lens API. I recommend using one of SerpApi's integrations for many popular programming languages:

SerpApi: Integrations

Using these integrations will allow you to export code directly from SerpApi's playground:

Export to code

SerpApi Playground - SerpApi

To get a better sense of how to write a script that performs image searches, check out these other blog posts:

Ready to Try It?

The Bulk Image Search tool solves all of these problems for you. It handles authentication with Imgur, uploading images to Imgur, batching requests to SerpApi, and returning more useful spreadsheet-ready formats (CSV and XSLX).

Visitย https://bulkimagesearch.com/ย to start searching your images in bulk.

Frequently Asked Questions

Is my API key safe?

Yes, your API key is encrypted and never stored in plaintext. It is only used to perform searches on your behalf. API keys are not stored in a database or server.

How do I handle "suspicious download" warnings?

Chrome may flag the ZIP file as suspicious when downloading bulk search results. You can safely proceed by clicking "download suspicious file" in Chrome's download bar.

I have a question or issue not answered here

For any additional questions or concerns, please get in touch with me at [email protected].

serpapi Article's
30 articles in total
Favicon
No-code Solutions for Turning Search Results Into Markdown for LLMs
Favicon
No-code Solutions for Turning Search Results Into Markdown for LLMs
Favicon
Turning search results into Markdown for LLMs
Favicon
Bulk Image Search with Google Lens
Favicon
What is UULE? And how to generate UULE with Python?
Favicon
How we reverse-engineered Google Maps pagination
Favicon
Real-time data for OpenAI Assistants API
Favicon
Playwrightโ€™s getByRole is 1.5x slower than CSS selectors
Favicon
When counting lines in Ruby randomly failed SerpApi deployments
Favicon
Insights from an Engineering Director (#SerpApiPodcast, Ep. 8)
Favicon
7500 hotels price research: scraping using JavaScript module hotels-scraper-js and data analysis
Favicon
JavaScript Hotels Parser
Favicon
SerpApi Changelog: January, 2023
Favicon
JavaScript SEO Keywords Research Tool: Google Autocomplete, People Also Ask, and People Also Search For
Favicon
Product Comparison App (JS Demo Project)
Favicon
SerpApi Changelog: December, 2022
Favicon
Web scraping Walmart Search with Nodejs
Favicon
Web scraping The Home Depot Search with Nodejs
Favicon
Web scraping The Home Depot Product Info with Nodejs
Favicon
Web scraping Apple App Store Product Info And Reviews with Nodejs
Favicon
Web scraping Google Lens Results with Nodejs
Favicon
Web scraping Apple App Store Search with Nodejs
Favicon
Web scraping Yelp Reviews with Nodejs
Favicon
Web scraping Yelp Filters with Nodejs
Favicon
Web scraping Yelp Organic And Ads Results with Nodejs
Favicon
Web scraping Google Shopping Product Specs with Nodejs
Favicon
Web scraping Google Shopping Product Reviews with Nodejs
Favicon
Web scraping Google Shopping Product Page with Nodejs
Favicon
Web scraping Google Arts & Culture Artist Results with Nodejs
Favicon
Web scraping Google Jobs Listing with Nodejs

Featured ones: