web-scrapingtripadvisor

R Selenium TripAdvisor detailed member info


I'm trying to get the detailed information about reviewer that wrote a certain review.

The problem is that reviewer's information pop-up, when you move to a certain section. I can do that with selenium.

url<-"https://www.tripadvisor.com/Hotel_Review-g644300-d668891-Reviews-Hotel_Creina-Kranj_Upper_Carniola_Region.html#REVIEWS"

driver<- rsDriver()
remDr <- driver[["client"]]


remDr$open()

remDr$navigate(url)

details <- remDr$findElement(using = "xpath", paste("(//div[@class='username mo'])"))

remDr$mouseMoveToLocation(webElement=details)

How can I get a memberid ? See image.


Solution

  • library(rvest)

    url<-"https://www.tripadvisor.co.kr/ShowUserReviews-g294197-d306114-r457560253-Grand_Hilton_Seoul-Seoul.html#CHECK_RATES_CONT"

    h<-read_html(url)

    id<-html_attr(html_node(h,".expand_inline"),"class")

    id is expand_inline scrname mbrName_9520BF5DXXXXX

    id2<-gsub("expand_inline scrname mbrName_","",id)

    id2 is 9520BF5DXXXXX

    indurl<-paste0("https://www.tripadvisor.co.kr/MemberProfile-a_uid.",id2)

    indinfo<-read_html(indurl)

    name<-html_text(html_node(indinfo,".nameText"));name