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:

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.

Last updated