0
$\begingroup$

Text mining on Amazon product review using R Program. I wasn't able to extract the particular product's review(i.e.If iphone 11 has 6k review, I need to extract all of it.) I'm getting only one column labelled x. enter image description here

Please let me know where I need to make necessary changes. I need those for performing sentiment analysis.

install.packages("rvest")    
library(rvest)
install.packages("xml2")
library(xml2)
install.packages("magrittr")    
library(magrittr)
url <-"https://www.amazon.in/Apple-iPhone-11-128GB-Black/product-reviews/B07XVLW7YK/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews"
apple <- NULL    
for(i in 1:100)
    {
      murl <- read_html(as.character(paste(url,i,sep = "=")))
      rev <- murl%>%
        html_nodes(".review-text")%>%
        html_text()
      apple <- c(apple,rev)
    }
$\endgroup$

1 Answer 1

0
$\begingroup$

Change your url to:

url <- "https://www.amazon.in/Apple-iPhone-11-128GB-Black/product-reviews/B07XVLW7YK/ref=cm_cr_arp_d_paging_btm_next_2?ie=UTF8&reviewerType=all_reviews&pageNumber"

Otherwise, as is what your current code is doing, you keep looping only the first page of reviews.

$\endgroup$
2
  • $\begingroup$ If I proceed with the link, I'm getting an error. w<-rowSums(tdm) Error in rowSums(tdm) : 'x' must be an array of at least two dimensions $\endgroup$ Oct 19, 2020 at 3:45
  • $\begingroup$ I am not sure what are your w or tdm.... $\endgroup$
    – F.X.
    Oct 19, 2020 at 17:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.