Web scraping Google Lens Results with Nodejs
Tags: webscraping, node, serpapi
Published: 2023-01-04 17:09:38

<h2 id='what'>What will be scraped</h2>

![what](https://user-images.githubusercontent.com/64033139/209465097-d1ca08eb-2736-4607-a4cc-91a854b8cd11.png)

<h2 id='serp_api'>Why use <a href="https://serpapi.com/google-lens-api">Google Lens API</a> from SerpApi?</h2>

Using API generally solves all or most problems that might get encountered while creating own parser or crawler. From webscraping perspective, our API can help to solve the most painful problems:

- Bypass blocks from supported search engines by solving CAPTCHA or IP blocks.
- No need to create a parser from scratch and maintain it.
- Pay for proxies, and CAPTCHA solvers.
- Don't need to use browser automation if there's a need to extract data in large amounts faster.

Head to the [Playground](https://serpapi.com/playground?engine=google_lens) for a live and interactive demo.

<h2 id='preparation'>Preparation</h2>

First, we need to create a Node.js\* project and add [`npm`](https://www.npmjs.com/) packages [`serpapi`](https://www.npmjs.com/package/serpapi) and [`dotenv`](https://www.npmjs.com/package/dotenv).

To do this, in the directory with our project, open the command line and enter:

```bash
$ npm init -y
```

And then:

```bash
$ npm i serpapi dotenv
```

\*<span style="font-size: 15px;">If you don't have Node.js installed, you can [download it from nodejs.org](https://nodejs.org/en/) and follow the installation [documentation](https://nodejs.dev/learn/introduction-to-nodejs).</span>

- SerpApi package is used to scrape and parse search engine results using SerpApi. Get search results from Google, Bing, Baidu, Yandex, Yahoo, Home Depot, eBay, and more.

- dotenv package is a zero-dependency module that loads environment variables from a `.env` file into `process.env`.

Next, we need to add a top-level "type" field with a value of "module" in our `package.json` file to allow [using ES6 modules in Node.JS](https://nodejs.org/api/packages.html#determining-module-system):

![ES6Module](https://user-images.githubusercontent.com/64033139/206865580-6b5326ee-ff65-4890-876e-78112047a03f.png)

For now, we complete the setup Node.JS environment for our project and move to the step-by-step code explanation.

<h2 id='serp_api_code_explanation'>Code explanation</h2>

First, we need to import `dotenv` from [`dotenv`](https://www.npmjs.com/package/dotenv) library, and `config` and `getJson` from [`serpapi`](https://www.npmjs.com/package/serpapi) library:

```javascript
import dotenv from "dotenv";
import { config, getJson } from "serpapi";
```

Then, we apply some config. Call `dotenv` [`config()`](https://www.npmjs.com/package/dotenv#user-content-config) method and set your SerpApi Private API key to global [`config`](https://github.com/serpapi/serpapi-javascript#configuration) object.

```javascript
dotenv.config();
config.api_key = process.env.API_KEY; //your API key from serpapi.com
```

- `dotenv.config()` will read your `.env` file, parse the contents, assign it to `process.env`, and return an object with a `parsed` key containing the loaded content or an `error` key if it failed.
- `config.api_key`allows you declare a global `api_key` value by modifying the config object.

Next, we write search `engine` and write the necessary search parameters for making a request:

```javascript
const engine = "google_lens"; // search engine
const params = {
  url: "https://user-images.githubusercontent.com/64033139/209465038-010d1e56-16db-41d6-9769-6707d6f57111.png", //Parameter defines the URL of an image to perform the Google Lens search
  hl: "en", // Parameter defines the language to use for the Google search
};
```

You can use the next search params:

- `url` Parameter defines the URL of an image to perform the Google Lens search.
- `hl` Parameter defines the language to use for the Google Lens search. It's a two-letter language code. (e.g., `en` for English, `es` for Spanish, or `fr` for French). Head to the [Google languages page](https://serpapi.com/google-languages) for a full list of supported Google languages.
- `no_cache` parameter will force SerpApi to fetch the App Store Search results even if a cached version is already present. A cache is served only if the query and all parameters are exactly the same. Cache expires after 1h. Cached searches are free, and are not counted towards your searches per month. It can be set to `false` (default) to allow results from the cache, or `true` to disallow results from the cache. `no_cache` and `async` parameters should not be used together.
- `async` parameter defines the way you want to submit your search to SerpApi. It can be set to `false` (default) to open an HTTP connection and keep it open until you got your search results, or `true` to just submit your search to SerpApi and retrieve them later. In this case, you'll need to use our [Searches Archive API](https://serpapi.com/search-archive-api) to retrieve your results. `async` and `no_cache` parameters should not be used together. `async` should not be used on accounts with [Ludicrous Speed](https://serpapi.com/plan) enabled.

Next, we declare the function `getResult` that gets data from the page and return it:

```javascript
const getResults = async () => {
  ...
};
```

In this function, we need to get `json` with results,[delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete) unnecessary keys from JSON, and return it.

```javascript
const results = await getJson(engine, params);
delete results.search_metadata;
delete results.search_parameters;
return results;
```

And finally, we run the `getResults` function and print all the received information in the console with the [`console.dir`](https://nodejs.org/api/console.html#consoledirobj-options) method, which allows you to use an object with the necessary parameters to change default output options:

```javascript
getResults().then((result) => console.dir(result, { depth: null }));
```

<h3 id='serp_api_output'>Output</h3>

```json
{
   "reverse_image_search":{
      "link":"https://www.google.com/search?tbs=sbi:AMhZZitWp1e8SyEO5dl4qkTCxU70zIpDW4BZqoAlVXqVRYoNA58nc3GQXbry3Wfl6SnzaHZ-xCdVfXXvQmYBmRz2VytmMNasi8-oL3MaHsJM80etUlB7YESZvKTW3gD6f49AdV9TV5A-Sm-Nl9p6tDjuCTPPO6XuZA"
   },
   "text_results":[
      {
         "text":"18",
         "link":"https://www.google.com/search?q=18&hl=en",
         "serpapi_link":"https://serpapi.com/search.json?device=desktop&engine=google&google_domain=google.com&hl=en&q=18"
      },
      {
         "text":"M",
         "link":"https://www.google.com/search?q=M&hl=en",
         "serpapi_link":"https://serpapi.com/search.json?device=desktop&engine=google&google_domain=google.com&hl=en&q=M"
      }
   ],
   "knowledge_graph":[
      {
         "title":"BMW i8",
         "subtitle":"Sports car",
         "link":"https://www.google.com/search?q=BMW+i8&kgmid=/m/080607h&hl=en&gl=US",
         "more_images":{
            "link":"https://www.google.com/search?q=BMW+i8&kgmid=/m/080607h&ved=0EOTpBwgAKAAwAA&source=.lens.button&tbm=isch&hl=en&gl=US",
            "serpapi_link":"https://serpapi.com/search.json?device=desktop&engine=google&gl=US&google_domain=google.com&hl=en&q=BMW+i8&tbm=isch"
         },
         "thumbnail":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS7p4dD_8PlhsKlZ_5N2szF0jRpzjc-KiboC0GrNmPQhFsd8rAH",
         "images":[
            {
               "title":"Image #1 for BMW i8",
               "source":"https://www.youtube.com/watch?v=fOXuBey9xo8",
               "link":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS7p4dD_8PlhsKlZ_5N2szF0jRpzjc-KiboC0GrNmPQhFsd8rAH",
               "size":{
                  "width":300,
                  "height":168
               }
            },
            {
               "title":"Image #2 for BMW i8",
               "source":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSLMCx-TtUdq5kmOhdczYL-PWIgaWtUntnHVAJWbbo7vin_obsM",
               "link":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS8sXyFSX0NjlLBQcQbJAC85f-Aw9WIEX2D-Y3by-C7pd23R3C2",
               "size":{
                  "width":276,
                  "height":182
               }
            }
         ]
      },
        ... and other knowledge graph results
   ],
   "visual_matches":[
      {
         "position":1,
         "title":"The 2023 BMW i8 M (All we know so far) - YouTube",
         "link":"https://www.youtube.com/watch?v=fOXuBey9xo8",
         "source":"youtube.com",
         "source_icon":"https://encrypted-tbn0.gstatic.com/favicon-tbn?q=tbn:ANd9GcQHQslzHLLyLc_qne5jxn7JocidlmUPyegZ8ojX3WVlorFk8BxW9a3vJWjDzN99UHVTqSaNBj_-6XykhxuVQfF3Ye7xScSWSuc2QHXi0a12CkVwBmo",
         "thumbnail":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS7p4dD_8PlhsKlZ_5N2szF0jRpzjc-KiboC0GrNmPQhFsd8rAH"
      },
        ... and other visual matches results
   ]
}
```

<h2 id='DIY_solution'>DIY solution</h2>

This section is to show the comparison between our solution and the DIY solution.

If you don't need an explanation, have a look at [the full code example in the online IDE](https://replit.com/@MikhailZub/Scrape-Google-Lens-with-NodeJS#index.js)

```javascript
import puppeteer from "puppeteer-extra";
import StealthPlugin from "puppeteer-extra-plugin-stealth";

puppeteer.use(StealthPlugin());

const searchParams = {
  imageUrl: "https://user-images.githubusercontent.com/64033139/209465038-010d1e56-16db-41d6-9769-6707d6f57111.png", //Parameter defines the URL of an image to perform the Google Lens search
  hl: "en", //Parameter defines the language to use for the Google search
};

const URL = `https://lens.google.com/uploadbyurl?url=${searchParams.imageUrl}&hl=${searchParams.hl}&gl=${searchParams.gl}`;

async function getResultsFromPage(page) {
  const reverseImageSearch = await page.evaluate(() => ({ link: document.querySelector(".z3qvzf .WpHeLc").getAttribute("href") }));
  const knowledgeGraphItems = await page.$$(".sHc5hf > div");
  const knowledgeGraph = [];
  for (const item of knowledgeGraphItems) {
    await item.click();
    await page.waitForTimeout(2000);
    const thumbnail = await item.$eval(".FH8DCc", (node) => node.getAttribute("src"));
    knowledgeGraph.push(
      await page.evaluate(
        (thumbnail) => ({
          title: document.querySelector(".DeMn2d").textContent,
          subtitle: document.querySelector(".XNTym").textContent,
          link: document.querySelector(".wNPKTe a").getAttribute("href"),
          moreImagesLink: document.querySelector(".XkkoHf + div .Tc2PU > a").getAttribute("href"),
          thumbnail,
          images: Array.from(document.querySelectorAll(".XkkoHf + div .Tc2PU .Y02Gld a")).map((el) => ({
            title: el.getAttribute("aria-label"),
            source: el.getAttribute("href"),
            link: el.querySelector("img").getAttribute("src"),
          })),
        }),
        thumbnail
      )
    );
  }
  const height = await page.evaluate(() => document.querySelector(".jXKZBd").scrollHeight);
  const scrollIterationCount = 5;
  for (let i = 0; i < scrollIterationCount; i++) {
    await page.mouse.wheel({ deltaY: height / scrollIterationCount });
    await page.waitForTimeout(2000);
  }
  const visualMatches = await page.evaluate(() => {
    return Array.from(document.querySelectorAll(".Vd9M6 a")).map((el) => ({
      title: el.getAttribute("aria-label"),
      link: el.getAttribute("href"),
      source: el.querySelector(".PlAMyb span").textContent,
      sourceIcon: el.querySelector(".PlAMyb img").getAttribute("src"),
      thumbnail: el.querySelector(".Me0cf img").getAttribute("src"),
    }));
  });
  await page.click("#text");
  await page.waitForTimeout(2000);
  const textResultsItems = await page.$$(".WfGljd[aria-label]");
  const textResults = [];
  for (const item of textResultsItems) {
    await page.click("#text");
    await page.waitForTimeout(2000);
    await item.click();
    await page.waitForTimeout(2000);
    textResults.push(
      await page.evaluate(() => ({
        text: document.querySelector(".C3t4Ke").textContent,
        link: document.querySelector("a[aria-label=Search]").getAttribute("href"),
      }))
    );
  }
  return { reverseImageSearch, textResults, knowledgeGraph, visualMatches };
}

async function getLensResults() {
  const browser = await puppeteer.launch({
    headless: true, // if you want to see what the browser is doing, you need to change this option to "false"
    args: ["--no-sandbox", "--disable-setuid-sandbox"],
  });

  const page = await browser.newPage();

  await page.setDefaultNavigationTimeout(60000);
  await page.goto(URL);

  const results = await getResultsFromPage(page);

  await browser.close();

  return results;
}

getLensResults().then((result) => console.dir(result, { depth: null }));
```

<h3 id='preparation'>Preparation</h3>

First, we need to add [`npm`](https://www.npmjs.com/) packages [`puppeteer`](https://www.npmjs.com/package/puppeteer), [`puppeteer-extra`](https://www.npmjs.com/package/puppeteer-extra) and [`puppeteer-extra-plugin-stealth`](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth) to control Chromium (or Chrome, or Firefox, but now we work only with Chromium which is used by default) over the [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) in [headless](https://developers.google.com/web/updates/2017/04/headless-chrome) or non-headless mode.

To do this, in the directory with our project, open the command line and enter:

```bash
$ npm i puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
```

📌Note: also, you can use `puppeteer` without any extensions, but I strongly recommended use it with `puppeteer-extra` with `puppeteer-extra-plugin-stealth` to prevent website detection that you are using headless Chromium or that you are using [web driver](https://www.w3.org/TR/webdriver/). You can check it on [Chrome headless tests website](https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html). The screenshot below shows you a difference.

![stealth](https://user-images.githubusercontent.com/64033139/173014238-eb8450d7-616c-42ae-8b2f-24eeb5fd5916.png)

<h3 id='process'>Process</h3>

We need to extract data from HTML elements. The process of getting the right CSS selectors is fairly easy via [SelectorGadget Chrome extension](https://selectorgadget.com/) which able us to grab CSS selectors by clicking on the desired element in the browser. However, it is not always working perfectly, especially when the website is heavily used by JavaScript.

We have a dedicated [Web Scraping with CSS Selectors](https://serpapi.com/blog/web-scraping-with-css-selectors-using-python/#css_gadget) blog post at SerpApi if you want to know a little bit more about them.

The Gif below illustrates the approach of selecting different parts of the results using SelectorGadget.

![how](https://user-images.githubusercontent.com/64033139/209465177-afd4a332-5fb0-42d3-a6c1-878f23d178cb.gif)

<h3 id='code_explanation'>Code explanation</h3>

Declare [`puppeteer`](https://www.npmjs.com/package/puppeteer-extra) to control Chromium browser from `puppeteer-extra` library and [`StealthPlugin`](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth) to prevent website detection that you are using [web driver](https://www.w3.org/TR/webdriver/) from `puppeteer-extra-plugin-stealth` library:

```javascript
const puppeteer = require("puppeteer-extra");
const StealthPlugin = require("puppeteer-extra-plugin-stealth");
```

Next, we "say" to `puppeteer` use `StealthPlugin`, write the search parameters and the search URL:

```javascript
puppeteer.use(StealthPlugin());

const searchParams = {
  imageUrl: "https://user-images.githubusercontent.com/64033139/209465038-010d1e56-16db-41d6-9769-6707d6f57111.png", //Parameter defines the URL of an image to perform the Google Lens search
  hl: "en", //Parameter defines the language to use for the Google search
};

const URL = `https://lens.google.com/uploadbyurl?url=${searchParams.imageUrl}&hl=${searchParams.hl}&gl=${searchParams.gl}`;
```

Next, we write a function to get results from the page:

```javascript
async function getResultsFromPage(page) {
  ...
}
```

In this function we'll use the next methods to get the necessary information:

- [`querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll);
- [`querySelector()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector);
- [`getAttribute()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute);
- [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent);
- [`Array.from()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from);

Then, we get link to the Google Reverse Image from the page context (using [`evaluate()`](https://pptr.dev/api/puppeteer.page.evaluate) method) and save it in the `reverseImageSearch` constant:

```javascript
const reverseImageSearch = await page.evaluate(() => ({ link: document.querySelector(".z3qvzf .WpHeLc").getAttribute("href") }));
```

Next, we get knowledge graph info. To do this, we need to get all `knowledgeGraphItems` from the page (with [`.$$()`](https://pptr.dev/api/puppeteer.page.__) method).

Then, using [`for...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loop we click ([`click()`](https://pptr.dev/api/puppeteer.elementhandle.click) method) on each `item` and get and add ([`push()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) method) information from this knowledge graph to the `knowledgeGraph` array:

```javascript
const knowledgeGraphItems = await page.$$(".sHc5hf > div");
const knowledgeGraph = [];
for (const item of knowledgeGraphItems) {
  await item.click();
  await page.waitForTimeout(2000);
  const thumbnail = await item.$eval(".FH8DCc", (node) => node.getAttribute("src"));
  knowledgeGraph.push(
    await page.evaluate(
      (thumbnail) => ({
        title: document.querySelector(".DeMn2d").textContent,
        subtitle: document.querySelector(".XNTym").textContent,
        link: document.querySelector(".wNPKTe a").getAttribute("href"),
        moreImagesLink: document.querySelector(".XkkoHf + div .Tc2PU > a").getAttribute("href"),
        thumbnail,
        images: Array.from(document.querySelectorAll(".XkkoHf + div .Tc2PU .Y02Gld a")).map((el) => ({
          title: el.getAttribute("aria-label"),
          source: el.getAttribute("href"),
          link: el.querySelector("img").getAttribute("src"),
        })),
      }),
      thumbnail
    )
  );
}
```

Next, we need to scroll the page to load all thumbnails (if we don't, we get only a 1x1 pixels size placeholder). To do this we get page height, set `scrollIterationCount` to define how parts we want to divide the page, and then scroll it ([`mouse.wheel()`](https://pptr.dev/api/puppeteer .mouse.wheel) method):

```javascript
const height = await page.evaluate(() => document.querySelector(".jXKZBd").scrollHeight);
const scrollIterationCount = 5;
for (let i = 0; i < scrollIterationCount; i++) {
  await page.mouse.wheel({ deltaY: height / scrollIterationCount });
  await page.waitForTimeout(2000);
}
```

Next, we get info for visual match results and save it in the `visualMatches` constant.

```javascript
const visualMatches = await page.evaluate(() => {
  return Array.from(document.querySelectorAll(".Vd9M6 a")).map((el) => ({
    title: el.getAttribute("aria-label"),
    link: el.getAttribute("href"),
    source: el.querySelector(".PlAMyb span").textContent,
    sourceIcon: el.querySelector(".PlAMyb img").getAttribute("src"),
    thumbnail: el.querySelector(".Me0cf img").getAttribute("src"),
  }));
});
```

To get the text results we click on the "Text" button, get all text items and set info from each item to the `textResults` array:

```javascript
await page.click("#text");
await page.waitForTimeout(2000);
const textResultsItems = await page.$$(".WfGljd[aria-label]");
const textResults = [];
for (const item of textResultsItems) {
  await page.click("#text");
  await page.waitForTimeout(2000);
  await item.click();
  await page.waitForTimeout(2000);
  textResults.push(
    await page.evaluate(() => ({
      text: document.querySelector(".C3t4Ke").textContent,
      link: document.querySelector("a[aria-label=Search]").getAttribute("href"),
    }))
  );
}
```

Then, we return the object with all the info that we get in this function:

```javascript
return { reverseImageSearch, textResults, knowledgeGraph, visualMatches };
```

Next, write a function to control the browser, and get information:

```javascript
async function getLensResults() {
  ...
}
```

In this function first we need to define `browser` using `puppeteer.launch({options})` method with current `options`, such as `headless: true` and `args: ["--no-sandbox", "--disable-setuid-sandbox"]`.

These options mean that we use [headless](https://developers.google.com/web/updates/2017/04/headless-chrome) mode and array with [arguments](https://peter.sh/experiments/chromium-command-line-switches/) which we use to allow the launch of the browser process in the online IDE. And then we open a new `page`:

```javascript
const browser = await puppeteer.launch({
  headless: true, // if you want to see what the browser is doing, you need to change this option to "false"
  args: ["--no-sandbox", "--disable-setuid-sandbox"],
});

const page = await browser.newPage();
```

Next, we change the default ([30 sec](https://github.com/puppeteer/puppeteer/blob/2a0eefb99f0ae00dacc9e768a253308c0d18a4c3/src/common/TimeoutSettings.ts#L17)) time for waiting for selectors to 60000 ms (1 min) for slow internet connection with [`.setDefaultNavigationTimeout()`](https://pptr.dev/api/puppeteer.page.setdefaultnavigationtimeout) method, go to `URL` with [`.goto()`](https://pptr.dev/api/puppeteer.page.goto) method:

```javascript
await page.setDefaultNavigationTimeout(60000);
await page.goto(URL);
```

Then we define the `results` array and save results from page to it:

```javascript
const results = await getResultsFromPage(page);
```

And finally, we close the browser, and return the received data:

```javascript
await browser.close();

return results;
```

Now we can launch our parser:

```bash
$ node YOUR_FILE_NAME # YOUR_FILE_NAME is the name of your .js file
```

<h3 id='output'>Output</h3>

```json
{
   "reverseImageSearch":{
      "link":"https://www.google.com/search?tbs=sbi:AMhZZis56hg-YEqgOHS8pa8l_1QxyQa2cxtCmEZoD71xt6dE6WPxXnbPXQV6EuTR9Yhnyb56yuK1pVQveu_1_1lXI49V16nuPJPYy5LFOIu9_16JkSKvotCdgwacqAKAxnmZ8mjkw0qYAZqvGzmkOCPnXM6oko0pADoQ4A"
   },
   "textResults":[
      {
         "text":"\"18\"",
         "link":"https://www.google.com/search?q=18%20"
      },
      {
         "text":"\"M\"",
         "link":"https://www.google.com/search?q=M"
      }
   ],
   "knowledgeGraph":[
      {
         "title":"BMW i8",
         "subtitle":"Sports car",
         "link":"https://www.google.com/search?q=BMW+i8&kgmid=/m/080607h&hl=en&gl=US",
         "moreImagesLink":"https://www.google.com/search?q=BMW+i8&kgmid=/m/080607h&ved=0EOTpBwgAKAAwAA&source=.lens.button&tbm=isch&hl=en&gl=US",
         "thumbnail":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS7p4dD_8PlhsKlZ_5N2szF0jRpzjc-KiboC0GrNmPQhFsd8rAH",
         "images":[
            {
               "title":"Image #1 for BMW i8",
               "source":"https://www.youtube.com/watch?v=fOXuBey9xo8",
               "link":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS7p4dD_8PlhsKlZ_5N2szF0jRpzjc-KiboC0GrNmPQhFsd8rAH"
            },
            {
               "title":"Image #2 for BMW i8",
               "source":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSLMCx-TtUdq5kmOhdczYL-PWIgaWtUntnHVAJWbbo7vin_obsM",
               "link":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS8sXyFSX0NjlLBQcQbJAC85f-Aw9WIEX2D-Y3by-C7pd23R3C2"
            }
         ]
      },
        ... and other knowledge graph results
   ],
   "visualMatches":[
      {
         "title":"The 2023 BMW i8 M (All we know so far) - YouTube",
         "link":"https://www.youtube.com/watch?v=fOXuBey9xo8",
         "source":"youtube.com",
         "sourceIcon":"https://encrypted-tbn0.gstatic.com/favicon-tbn?q=tbn:ANd9GcQHQslzHLLyLc_qne5jxn7JocidlmUPyegZ8ojX3WVlorFk8BxW9a3vJWjDzN99UHVTqSaNBj_-6XykhxuVQfF3Ye7xScSWSuc2QHXi0a12CkVwBmo",
         "thumbnail":"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS7p4dD_8PlhsKlZ_5N2szF0jRpzjc-KiboC0GrNmPQhFsd8rAH"
      },
        ... and other visual matches results
   ]
}
```

<h2 id='links'>Links</h2>

- [Google Lens API Documentation](https://serpapi.com/google-lens-api)
- [Google Lens API Playground](https://serpapi.com/playground?engine=google_lens)

If you want other functionality added to this blog post or if you want to see some projects made with SerpApi, [write me a message](mailto:miha01012019@gmail.com).

---

<p style="text-align: center;">Join us on <a href="https://twitter.com/serp_api">Twitter</a> | <a href="https://www.youtube.com/channel/UCUgIHlYBOD3yA3yDIRhg_mg">YouTube</a></p>
<p style="text-align: center;">Add a  <a href="https://github.com/serpapi/public-roadmap/issues">Feature Request</a>💫 or a <a href="https://github.com/serpapi/public-roadmap/issues">Bug</a>🐞</p>