Google Lens is a powerful search tool. Google uses the latest technology to analyze images and provide useful information. Google Lens can recognize text, objects, people, plants, animals, etc.

You can use Google Lens to search for information about a product, or similar images.

SerpApi is the leading SERP API solution and we also provide a high-quality Google Lens API. Scraping Google Lens results can help you to collect data on objects, text, people, and more to use for training machine learning models or creating new AI applications.

Let's see how it works with SerpApi Google Lens API.

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 the results, you can utilize SERP APIs using your API Key.

Scrape your First Google Lens Results with SerpApi

Head to the Google Lens Results from the documentation on SerpApi for details.

In this tutorial, we will scrape all videos related to an AirPod product. The data contains: "title", "link", "source", "profile_name", "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, csv

params = {
    'api_key': 'YOUR_API_KEY',             # your serpapi api
    'engine': 'google_lens',        # SerpApi search engine
    'url': 'https://encrypted-tbn1.gstatic.com/shopping?q=tbn:ANd9GcT27QuyhDk7UGeqc-sOA_Vs9BJp--vhGzxP6Ws3l7nH5EffyAJ0PJK3SPcLPqxq3lQKJ8-i3CIQ-QD_lLevz3dZPfW4Dy_p&usqp=CAY'
}

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

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

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

import csv

header = ["title", "link", "source", "profile_name", "video", "thumbnail"]

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

    writer.writerow(header)

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

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

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