How To

Learn about the different targeting options, control panel configurations, advanced actions, and more with Bright Data’s SERP API.

Getting Started

If you haven't yet seen our SERP API Getting started guide, you'll want to go there first to briefly review how to create and configure a SERP API zone, send your first request, and collect data from search engine results pages.

How to: for All Proxy networks

Learn how to Integrate the SERP API proxy solution into your code, Whitelist/blacklist IPs and domains, target a specific country or city when sending your request, set a limit on bandwidth consumption, integrations, statistics, and more with your SERP API zone 

How to: SERP API Specific

Explore our SERP API documentation, see how to use our SERP API tool to search for images and hotel data, learn how to send Asynchronous requests and why this feature is recommended, and see the various ways to send requests to the SERP API.

How to use SERP API for "Google Search By Image"

With Bright Data’s SERP API, it’s easy to collect Google Search by Image data.

Google reverse image search (officially "Google Search by Image"), is a service provided by Google that allows users to search for images using an image as the starting point, rather than a written or spoken search query.

The API supports:

  • Adding a query to the image
  • Searching for an image’s URL
  • Searching for an image stored locally
    Note: The JSON response includes the image in base64 encoding.

Examples

  • Search by image URL:
    curl -v --compressed --proxy brd.superproxy.io:22225 --proxy-user brd-customer-{ACCOUNT_ID}-zone-{ZONE}:{PASSWORD} "https://www.google.com/searchbyimage?image_url={TARGET_IMAGE_URL}"
  • Search by an image stored locally:
    curl -v --compressed --proxy brd.superproxy.io:22225 --proxy-user brd-customer-{ACCOUNT_ID}-zone-{ZONE}:{PASSWORD} 'http://www.google.com/searchbyimage/upload' -o results_page.html -F 'encoded_image=@{FULL_IMAGE_FILE_PATH}'

See the rest of our Google Image SERP features.

How to collect hotel data with SERP API

Bright Data’s SERP API makes it easy to collect hotel data, like prices, availability, reviews, and more. 

There are two ways to collect hotel data:

  1. Google Search hotel knowledge graph/widget - limited info per specific hotel on pricing and dates
  2. Google Travel hotels page (google.com/travel) - full details on hotels, pricing, and dates

Note: #1 above can be scraped via a regular SERP API request. However, to collect hotel data from Google Travel (#2), you’ll need to enable the Hotels permission in your SERP API zone since this requires extra resources from SERP API.

1. Google Search hotel widget

When you search for a specific hotel using Google Search, its details and reviews appear in the knowledge graph/widget that you can see on the right side below:

mceclip1.png

You can set arrival and departure dates, the number of guests, and compare pricing.. 

With SERP API, you can set these fields to collect different price combinations using dedicated parameters. See the full set of hotel parameters and features within our API documentation

mceclip2.png

2. Google Travel hotels page (google.com/travel)

SERP API also lets you target the hotel page in Google Travel (Google.*/travel/hotels/…), where you can find more prices and search by additional parameters (including arrival and departure dates, the number of adults and children, the children’s ages, and whether or not it has free cancellation) to collect more price combinations. 

Notes:

  • Only //Google.*/travel/hotels/… URLs are supported.
  • To target a hotel page on Google Travel, you need to enable the Hotels permission in your SERP API zone. This service is provided at an additional cost (due to extra resources needed for this page), so we recommend creating an additional dedicated SERP zone that will be used to make /travel/hotels/… API requests.

All other SERP requests should be made from a SERP zone where the Hotels permission isn’t enabled.

  • Go to the control panel API Guide for an explanation of how to target this page and the dedicated parameters you can use or see our API documentation

mceclip3.png

How to send SERP API HTTPS requests

When targeting HTTPS, URL data is encrypted. Therefore, for SERP API to decrypt the data and return the result, you will need to download and install the Bright Data Certificate or skip the SSL validation.

Here are explanations on how to send HTTPS requests:

Sending HTTPS requests without SSL validation

Shell
Use --insecure or -k flag

curl -v --insecure--compressed --proxy brd.superproxy.io:22225 --proxy-user brd-customer-<ACCOUNT_ID>-zone-<ZONE>:<PASSWORD>"https://www.google.com/search?q=pizza&lum_json=1"

Node.js 

process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;

Java

Add the following argument to the JVM:

-Dcom.sun.net.ssl.checkRevocation=false

C#

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

Python

import sslssl._create_default_https_context = ssl._create_unverified_context

 

Sending HTTPS requests with SSL validation

Shell
Use the '--cacert' flag followed by the certificate file path:

curl -v --compressed --cacert “{cert file path}“ --proxy brd.superproxy.io:22225 --proxy-user brd-customer-{ACCOUNT_ID}-zone-{ZONE}:{PASSWORD} "https://www.google.com/search?q=pizza&lum_json=1"

Java

Import the certificate to the Java Keystore.

Here's an example using Java keytool to import the certificate:

%JAVA_HOME% Keystore (mostly the cacerts file in ..\lib\security\).

Keytool command example:

keytool -import -alias <cert alias> -file <cert name>.cer -keystore <keystore filename> -storepass <keystore password>

After running the keytool command you will be prompted to trust the certificate: answer ‘y’ 

Other code Languages

Follow the instructions in the following article on how to download and Install the Bright Data certificate to your local machine's Trusted Root Certification Authorities.T_ID&zone={ASYNC_ZONE}&output={output_fomat_html/json}&response_id={response_id}" -H "Authorization: Bearer {API_Token}" -o {Your_result_ouput_file)

Was this article helpful?