Google Play网络抓取:如何在R中识别对应用评论的反应?

时间:2019-11-07 16:25:13

标签: r web-scraping google-play app-store rstudio

我正在用R抓取Google Play应用程序的评论进行Web抓取,但是我无法确定对评论的回应不足。

我解释。我打算建立一个包含两列的数据库。一个带有评论文字,另一列带有应用对该评论的回复。在最后一列中,如果没有响应,它将具有空值。但是,我只能得到答案,而无法确定没有答案。该怎么办?

输入

enter image description here

输出 我想退回的物品

enter image description here

我如何得到这个?确定没有响应

完整代码

#Loading the rvest package
library(rvest)
library(magrittr) # for the '%>%' pipe symbols
library(RSelenium) # to get the loaded html of 


url <- 'https://play.google.com/store/apps/details?id=com.gospace.parenteral&showAllReviews=true'

# starting local RSelenium (this is the only way to start RSelenium that is working for me atm)
selCommand <- wdman::selenium(jvmargs = c("-Dwebdriver.chrome.verboseLogging=true"), retcommand = TRUE)
shell(selCommand, wait = FALSE, minimized = TRUE)
remDr <- remoteDriver(port = 4567L, browserName = "firefox")
remDr$open()

# go to website
remDr$navigate(url)


# get page source and save it as an html object with rvest
html_obj <- remDr$getPageSource(header = TRUE)[[1]] %>% read_html()

#1 column
reviews <- html_obj %>% html_nodes(".UD7Dzf") %>% html_text()

#2 column
reply <- html_obj %>% html_nodes('.LVQB0b') %>% html_text()


# create the df with all the info
review_data <- data.frame(reviews = reviews, reply = reply, stringsAsFactors = F)

0 个答案:

没有答案