Skip to contents

Scrape Google Maps' reviews

Usage

google_maps(
  client,
  name,
  place_id = NULL,
  base = "https://www.google.com/maps/search/?api=1&query=",
  sleep = 1,
  max_reviews = 100,
  result_id = 1,
  with_text = FALSE
)

Arguments

client

RSelenium client.

name

String with the name of the target place.

place_id

String with the unique ID of the target place, useful when more than one place has the same name.

base

String with the base URL for Google Maps website.

sleep

Integer with number of seconds to use as pause between actions on the web page.

max_reviews

Integer with the maximum number of reviews to scrape. The number of existing reviews will define the actual number of reviews returned.

result_id

Integer with the result position to use, only relevant when multiple matches for the given name are found.

with_text

Boolean value to indicate if the max_reviews should only account for those reviews with a comment.

Value

Tibble with the reviews extracted from Google Maps.

Examples

if (FALSE) {
# Create RSelenium session
rD <- RSelenium::rsDriver(browser = "firefox", port = 4544L, verbose = FALSE)
# Retrieve reviews for Sefton Park in Liverpool
sefton_park_reviews_tb <-
  scrappy::google_maps(
    client = rD$client,
    name = "Sefton Park",
    place_id = "ChIJrTCHJVkge0gRm1LWF0fSPgw",
    max_reviews = 20
  )

sefton_park_reviews_tb_with_text <-
  scrappy::google_maps(
    client = rD$client,
    name = "Sefton Park",
    place_id = "ChIJrTCHJVkge0gRm1LWF0fSPgw",
    max_reviews = 20,
    with_text = TRUE
  )
# Stop server
rD$server$stop()
}