R Selenium TripAdvisor详细的会员信息

时间:2017-08-24 09:01:30

标签: web-scraping tripadvisor

我试图获取撰写某篇评论的评论者的详细信息。

当您移动到某个部分时,问题是评论者的信息会弹出。我可以用硒来做到这一点。

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)

我如何获得会员? See image

1 个答案:

答案 0 :(得分:0)

库(rvest)

URL&LT; - &#34; https://www.tripadvisor.co.kr/ShowUserReviews-g294197-d306114-r457560253-Grand_Hilton_Seoul-Seoul.html#CHECK_RATES_CONT&#34;

H&LT; -read_html(URL)

ID&LT; -html_attr(html_node(H,&#34; .expand_inline&#34;),&#34;类&#34)

id是expand_inline scrname mbrName_9520BF5DXXXXX

id2&lt; -gsub(&#34; expand_inline scrname mbrName _&#34;,&#34;&#34;,id)

id2是9520BF5DXXXXX

indurl&LT; -paste0(&#34; https://www.tripadvisor.co.kr/MemberProfile-a_uid&#34;,ID2)

indinfo&LT; -read_html(indurl)

名&LT; -html_text(html_node(indinfo,&#34; .nameText&#34));名称