The google_maps source is designed to retrieve Google Local search results. It scrapes various location-based data, such as restaurants, hotels, coffee shops, gas stations, grocery stores, and more.
Request samples
In this example, we make a request to retrieve the first 3 pages of hotel availability for 1 guest between 2023-10-01 and 2023-10-10 for hotels in Paris from google.com.sons.
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
namespace OxyApi
{
class Program
{
static async Task Main()
{
const string Username = "USERNAME";
const string Password = "PASSWORD";
var parameters = new {
source = "google_maps",
domain = "com",
pages = 3,
query = "hotels in Paris",
context = new dynamic [] {
new { key = "hotel_occupancy", value = 1 },
new { key = "hotel_dates", value = "2023-10-01,2023-10-10" }
}
};
var client = new HttpClient();
Uri baseUri = new Uri("https://realtime.oxylabs.io");
client.BaseAddress = baseUri;
var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/v1/queries");
requestMessage.Content = JsonContent.Create(parameters);
var authenticationString = $"{Username}:{Password}";
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);
var response = await client.SendAsync(requestMessage);
var contents = await response.Content.ReadAsStringAsync();
Console.WriteLine(contents);
}
}
}
package org.example;
import okhttp3.*;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.concurrent.TimeUnit;
public class Main implements Runnable {
private static final String AUTHORIZATION_HEADER = "Authorization";
public static final String USERNAME = "USERNAME";
public static final String PASSWORD = "PASSWORD";
public void run() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("source", "google_maps");
jsonObject.put("domain", "com");
jsonObject.put("pages", 3);
jsonObject.put("query", "hotels in Paris");
jsonObject.put("context", new JSONArray()
.put(new JSONObject()
.put("key", "hotel_occupancy")
.put("value", 1))
.put(new JSONObject()
.put("key", "hotel_dates")
.put("value", "2023-10-01,2023-10-10"))
);
Authenticator authenticator = (route, response) -> {
String credential = Credentials.basic(USERNAME, PASSWORD);
return response
.request()
.newBuilder()
.header(AUTHORIZATION_HEADER, credential)
.build();
};
var client = new OkHttpClient.Builder()
.authenticator(authenticator)
.readTimeout(180, TimeUnit.SECONDS)
.build();
var mediaType = MediaType.parse("application/json; charset=utf-8");
var body = RequestBody.create(jsonObject.toString(), mediaType);
var request = new Request.Builder()
.url("https://realtime.oxylabs.io/v1/queries")
.post(body)
.build();
try (var response = client.newCall(request).execute()) {
if (response.body() != null) {
try (var responseBody = response.body()) {
System.out.println(responseBody.string());
}
}
} catch (Exception exception) {
System.out.println("Error: " + exception.getMessage());
}
System.exit(0);
}
public static void main(String[] args) {
new Thread(new Main()).start();
}
}
Device type and browser. The full list can be found here.
desktop
- mandatory parameter
Localization
Adapt search results to specific geographical locations, domains, and languages.
Parameter
Description
Default Value
geo_location
The geographical location that the result should be adapted for. Using this parameter correctly is extremely important to get the right data. For more information, read about our suggested geo_location parameter structures here.
-
domain
Domain localization for Google. The full list of available domains can be found here.
com
locale
Accept-Language header value which changes your Google search page web interface language. More info.
-
context:
results_language
Results language. List of supported Google languages can be found here.
-
Pagination
Controls for managing the pagination and retrieval of search results.
Parameter
Description
Default Value
start_page
Starting page number.
1
pages
Number of pages to retrieve.
1
limit
Number of results to retrieve in each page.
10
Other
Additional advanced settings and controls for specialized requirements.
Parameter
Description
Default Value
context:
nfpr
true will turn off spelling auto-correction
false
context:
hotel_occupancy
Number of guests.
NB: this parameter is only applicable if you are searching for a hotel-related search term.
-
context:
hotel_dates
Length for staying in the hotel, from - to. Example: 2023-07-12,2023-07-13
NB: this parameter is only applicable if you are searching for a hotel-related search term.
Context parameters
All context parameters should be added to the context array as objects with key and value pairs, e.g.: