villegar / scrappy

A Simple Web Scraper
https://scrappy.robertovillegas-diaz.com/
Other
4 stars 0 forks source link

Separate Google Maps' comments #4

Open villegar opened 1 year ago

villegar commented 1 year ago

There are cases in which the comment associated to a review has been written using a different language (other than English), Google automatically translates these comments:

(Translated by Google) A very well-kept park (Original) Un parque may bien mantenido

In such cases, it would be useful to separate the comments into original and translated columns, or at least to offer the option to separate these comments.

oceandiscovery commented 2 months ago

Hi Villegar,

Thank you for sharing your script. I was wondering if you could help modify the google_maps function to include a new feature? Specifically, could it be adapted to load the entire comment when a comment is truncated and displays a “Read more” button? Here’s an example for reference.

Thanks again for your assistance!

# Function to click all "Read more" links
click_read_more <- function(driver) {
  repeat {
    read_more_buttons <- driver$findElements(using = "css selector", ".w8nwRe.kyuRq")
    if (length(read_more_buttons) == 0) {
      break
    }
    for (button in read_more_buttons) {
      button$clickElement()
      Sys.sleep(1)  # Small delay to ensure click is registered
    }
    Sys.sleep(2)  # Wait for new content to load after clicking
  }
}