Google Search API
Scrape Google Search and get real time, location based results, without worrying about captchas.
To enable this engine, set the engine=google parameter.
Scraping Google Search results takes a lot of effort in the background, as Google has multiple ways to detect and prevent scrapers. Luckily, with the Google API, you don't have to deal with anything other than sending the GET request to our endpoint, and our engine will return you the data in almost no time.
Scrape Google Search Results

Google Search API Integration Examples

We will use following URL as an example for this request:
https://serpapi.webscrapingapi.com/v1?engine=google&api_key=<YOUR_API_KEY>&q=history

Ready to Use Google Search Scraping Scripts:

cURL
NodeJS
Python
PHP
Go
Java
.NET
Ruby
curl --request GET --url "https://serpapi.webscrapingapi.com/v1?engine=google&api_key=<YOUR_API_KEY>&q=history"
const http = require("https");
const options = {
"method": "GET",
"hostname": "serpapi.webscrapingapi.com",
"port": null,
"path": "/v1?engine=google&api_key=YOUR_API_KEY&q=history",
"headers": {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
import http.client
conn = http.client.HTTPSConnection("serpapi.webscrapingapi.com")
conn.request("GET", "/v1?engine=google&api_key=YOUR_API_KEY&q=history")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://serpapi.webscrapingapi.com/v1?engine=google&api_key=YOUR_API_KEY&q=history",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://serpapi.webscrapingapi.com/v1?engine=google&api_key=YOUR_API_KEY&q=history"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.get("https://serpapi.webscrapingapi.com/v1?engine=google&api_key=YOUR_API_KEY&q=history")
.asString();
var client = new RestClient("https://serpapi.webscrapingapi.com/v1?engine=google&api_key=YOUR_API_KEY&q=history");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://serpapi.webscrapingapi.com/v1?engine=google&api_key=YOUR_API_KEY&q=history")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body

Google Search Specific Parameters

#1: Query Parameter

Parameter
Type
Description
q Required
string
The keywords that you are searching for on Google (the query).

#2: Request Customisation Parameters

Parameter
Type
Description
cookie
string
Set a custom cookies for your Google search. The string must be url encoded.
tbm
string
The parameter defines the type of search you want to do. It can be:
- isch for images
- vidfor videos
- nws for news
- shop for shopping. * If left unset it will continue with the regular Google search.
sort_by
string
Sorts the results. It can be set to relevance or date.
time_period
string
The period of time for the results. Can be set to last_hour, last_day, last_week, last_month, last_year or custom
time_period_min
string
The minimum value for time period when the time_period parameter is set to custom. Format: MM/DD/YYYY
time_period_max
string
The maximum value for time period when the time_period parameter is set to custom. Format: MM/DD/YYYY
flatten_results
int
Whether or not to flatten the results. It can be set to 1 (to flatten results) or 0.
empty_results
int
Can be set to 0 (to hide empty results) or 1 (to display empty results).

#3: Device and Geolocation Parameters

Parameter
Type
Description
device
string
The device used for your Google search. Can be set to desktop, mobile or tablet.
location
string
Defines where you want the search to originate from. A list of all the geotargeting locations can be found here.
google_domain
string
The Google domain that you want to use for your search.
uule
string
The Google encoded location that you want to use for your search.
lr
string
One or multiple languages to limit your search to. Values are formatted as lang_{2 letter code of the country} You can find all the available languages here
hl
string
The language you want to use for your Google search. List of supported languages
gl
string
The country you want to use for your Google search. List of supported countries

#4: Pagination Parameters

Parameter
Type
Description
start
int
The offset of the Google Search results. Represents the number of results that you want to skip.
num
int
The number of results returned on each page.
ijn
int
Parameter defines the page number for Google Images. There are 100 images per page. This parameter is equivalent to start (offset) = ijn * 100.

#5: Advanced Filtering Parameters

Parameter
Type
Description
safe
string
This parameter allows you to filter the adult content displayed in Google Search results. It can take the values active and off.
filter
int
Defines if the filters for similar results and omitted results are on (set to 1) or off (set to 0).
nfpr
int
Defines if it should exclude or not the auto-corrected query. Can have the value 1 to exclude results or 0 otherwise.
tbs
string
The parameter defines advanced search parameters that aren't possible in the regular query field. (e.g., advanced search for patents, dates, news, videos, images, apps, or text contents).
ludocid
string
Defines the id (CID) of the Google My Business listing you want to scrape. Also known as Google Place ID.
lsig
int
Force the Knowledge Graph map view to show up.
Response Example
Copy link
Outline
Google Search API Integration Examples
Ready to Use Google Search Scraping Scripts:
Google Search Specific Parameters