LogoLogo
Release NotesDataPipelineFAQs
Ruby
Ruby
  • Making Requests
    • API Endpoint Method
    • Proxy Port Method
    • SDK Method
    • Async Requests Method
      • How to use
      • Callbacks
      • API Parameters
      • Async Batch Requests
      • Decoding
    • Structured Data Collection Method
      • Amazon Product Page API
      • Amazon Search API
      • Amazon Offers API
      • Amazon Reviews API
      • Ebay Product Page API
      • Ebay Search API
      • Google SERP API
      • Google News API
      • Google Jobs API
      • Google Shopping API
      • Google Maps Search API
      • Redfin Agent Details API
      • Redfin 'For Rent' Listings API
      • Redfin 'For Sale' Listings API
      • Redfin Listing Search API
      • Walmart Search API
      • Walmart Category API
      • Walmart Product API
      • Walmart Reviews API
    • Async Structured Data Collection Method
      • Amazon Product Page API (Async)
      • Amazon Search API (Async)
      • Amazon Offers API (Async)
      • Amazon Reviews API (Async)
      • Ebay Product Page API (Async)
      • Ebay Search API (Async)
      • Google Search API (Async)
      • Google News API (Async)
      • Google Jobs API (Async)
      • Google Shopping API (Async)
      • Google Maps Search API (Async)
      • Redfin Agent Details API (Async)
      • Redfin 'For Rent' Listings API (Async)
      • Redfin 'For Sale' Listings API (Async)
      • Redfin Listing Search API (Async)
      • Walmart Search API (Async)
      • Walmart Category API (Async)
      • Walmart Product API (Async)
      • Walmart Reviews API (Async)
    • Making POST/PUT Requests
    • Customizing Requests
      • Amazon ZIP Code Targeting
      • Cached Results
      • Cost Control
      • Custom Headers
      • Device Type
      • Geotargeting
      • Geotargeting (Premium)
      • Parameters as Headers
      • Premium Residential/Mobile Proxy Pools
      • Rendering Javascript
        • Render Instruction Set
        • Screenshot Capture🆕
      • Sessions
  • Handling and Processing Responses
    • API Status Codes
    • Output Formats
      • JSON Response - Autoparse 📜
      • LLM Output Formats 💻
    • Response Encoding and Content-Type
  • Dashboard & Billing
    • API Key
    • Credit Usage
    • Delete Account
    • Invoice History
    • Billing Email
    • Billing Address
    • VAT Number
    • Payment Method
    • Cancel Subscription
  • Credits and Requests
  • Account Information
  • Documentation Overview
Powered by GitBook

Quick links

  • Homepage
  • Dashboard
  • Pricing
  • Contact Sales

Resources

  • Developer Guides
  • Blog
  • Contact Support
  • Learning Hub
On this page

Was this helpful?

  1. Making Requests
  2. Async Structured Data Collection Method

Google Search API (Async)

This endpoint will retrieve search data from a Google search result page and transform it into usable JSON.

Single Query Request:

require 'net/http'
require 'json'
require 'uri'
uri = URI('https://async.scraperapi.com/structured/google/search')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
  apiKey: 'APIKEY',
    query: 'QUERY',
    tld: 'TLD',
    uule: 'UULE',
    num: 'NUM',
    hl: 'HOSTLANGUAGE',
    gl: 'GUESTLANGUAGE',
    ie: 'QUERYENCODING',
    oe: 'RESULTENCODING',
    start: 'START',  callback: {
    type: 'webhook',
    url: 'CALLBACK'
  }
}.to_json
begin
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
  puts response.body
rescue => e
  puts "Error: #{e.message}"
end

Multiple Query Request:

require 'net/http'
require 'json'
require 'uri'
uri = URI('https://async.scraperapi.com/structured/google/search')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
  apiKey: 'APIKEY',
    query: ['QUERY1', 'QUERY2', 'QUERY3'],
    tld: 'TLD',
    uule: 'UULE',
    num: 'NUM',
    hl: 'HOSTLANGUAGE',
    gl: 'GUESTLANGUAGE',
    ie: 'QUERYENCODING',
    oe: 'RESULTENCODING',
    start: 'START',  callback: {
    type: 'webhook',
    url: 'CALLBACK'
  }
}.to_json
begin
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
  puts response.body
rescue => e
  puts "Error: #{e.message}"
end

Multiple Parameters can be used with this method:

REQUIRED

APIKEY

User account’s normal API key.

QUERY

Google Search Query.

OPTIONAL

TLD

Set this value to scrape the respective Google domain. Valid values include tlds for those countries or regions where Google has a search engine:

COUNTRY

Valid values are two letter country codes for which we offer Geo Targeting (e.g. “au”, “es”, “it”, etc.).

Where a Google domain needs to be scraped from another country (e.g. scraping Google.com from Canada, both TLD and COUNTRY parameters must be specified.

We also support Google Search parameters for this endpoint.

UULE: Set a region for a search. For example: w+CAIQICINUGFyaXMsIEZyYW5jZQ.

For example: DE IE: Character encoding how the engine interpret the query string. For example: UTF8 OE: Character encoding used for the results. For example: UTF8 START: Set the starting offset in the result list. When start=10 set the first element in the result list will be the 10th search result (meaning it starts with page 2 of results if the "num" is 10)

Sample Response

Single Query Request:

{
	"id": "89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"status": "running",
	"statusUrl": "https://async.scraperapi.com/structured/google/search/89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"query": "webscraping"
}

Multiple Query Request:

[
	{
		"id": "2955ad23-c812-475c-bc52-572576815d78",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/google/search/2955ad23-c812-475c-bc52-572576815d78",
		"query": "webscraping"
	},
	{
		"id": "120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"status": "running",
		"statusUrl": "https://async.scraperapi.com/structured/google/search/120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"query": "data grabbing"
	}
]

After the job(s) finish, you will find the result under the response key in the response JSON object. The structure is the same as in the corresponding SYNC data endpoint.

PreviousEbay Search API (Async)NextGoogle News API (Async)

Last updated 1 year ago

Was this helpful?

ae: ()

ca: ()

cn: ()

co.jp: ()

co.uk: ()

com: ()

com.au: ()

com.be: ()

com.br: ()

com.mx: ()

com.tr: ()

de: ()

eg: ()

es: ()

fr: ()

in: ()

it: ()

nl: ()

pl: ()

sa: ()

se: ()

sg: ()

You can find an online UULE generator here: NUM: Number of results HL: Host Language. For example: DE GL: Boosts matches whose country of origin matches the parameter value.

google.ae
google.ca
google.cn
google.co.jp
google.co.uk
google.com
google.com.au
google.com.be
google.com.br
google.com.mx
google.com.tr
google.de
google.eg
google.es
google.fr
google.in
google.it
google.nl
google.pl
google.sa
google.se
google.sg
https://site-analyzer.pro/services-seo/uule/