3

I am attempting to scrape REI's Reviews (Hammocks) using Rselarium and Rvest. I want to hit the button at the bottom x amount of times so I can scrape all the reviews. I'm a little lost. Here's what I have so far. If you know too, how to preview in the finder what you're doing (not screen print) that would be cool. Thanks Stack Community.

    replicate(100,
          {
remDr$navigate("https://www.amazon.com/Eagles-Nest-Outfitters-DoubleNest-Portable/product-reviews/B00K30GXK8/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviewshttps://www.amazon.com/Eagles-Nest-Outfitters-DoubleNest-Portable/product-reviews/B00K30GXK8/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews")
webElem <- remDr$findElement("css", "body")
webElem$sendKeysToElement(list(key = "end"))
morereviews <- remDr$findElement(using = 'css selector', ".a-last a")
morereviews$clickElement
Sys.sleep(4)

reviews <- xml2::read_html(remDr$getPageSource()[[1]])%>%
  rvest::html_nodes(".review-text")%>%
  dplyr::data_frame(reviews = .)
})
2
  • Any helps/hints would be appreciated... Commented Aug 17, 2018 at 15:51
  • Stack I'm stuck here. Commented Aug 20, 2018 at 2:15

1 Answer 1

4

Try this:

# Click the Load More button
replicate(100,
          {
            # scroll down
            webElem <- remDr$findElement("css", "body")
            webElem$sendKeysToElement(list(key = "end"))
            # find button
            morereviews <- remDr$findElement(using = 'css selector', "#BVRRContainer div.bv-content-pagination-container button")
            # click button
            morereviews$clickElement()
            # wait
            Sys.sleep(4)
          })

# Scrap the reviews
reviews <- xml2::read_html(remDr$getPageSource()[[1]])%>%
  rvest::html_nodes("#BVRRContainer div.bv-content-summary-body-text") %>%
  rvest::html_text() %>%
  dplyr::data_frame(reviews = .)
reviews
Sign up to request clarification or add additional context in comments.

5 Comments

Still struggling with turning the page. Any ideas?
No. The page refreshes but doesn't actually change the page. I thought it was the selector (and may be) but I think I have tried every combination. What do you think Pol. BTW, I sent and email to you. Not sure if you got it.
Still can't figure this darn thing out... Are the page buttons Java or some other thing? Help stack.
I noticed that you edited your question and changed the url you are scraping (rei vs amazon), so it's normal that the code of this answer won't work. Why did you change the url? You should go back to the last version of this question (since it has this solution which worked) and open a new one with this new url and explaining what you're trying to accomplish so we can help you with this new one.
Oh I didn't want to create a new one. I will though. That makes it cleaner. Thanks. Sorry for confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.