Как выполнить очистку веб-страниц, чтобы получить все отзывы о приложении в Google Play? - PullRequest
0 голосов
/ 28 октября 2019

Я делаю вид, что могу получить все отзывы о приложениях, которые пользователи оставляют в Google Play. У меня есть этот код, который они указали там Веб-слом в R через Google PlayStore . Но проблема в том, что вы получаете только первые 40 отзывов. Есть ли возможность получить все комментарии приложения?

`` `

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

#Specifying the url for desired website to be scrapped
url <- 'https://play.google.com/store/apps/details? 
id=com.phonegap.rxpal&hl=en_IN&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) name field (assuming that with 'name' you refer to the name of the 
reviewer)
names <- html_obj %>% html_nodes(".kx8XBd .X43Kjb") %>% html_text()

# 2) How much star they got 
stars <- html_obj %>% html_nodes(".kx8XBd .nt2C1d [role='img']") %>% 
html_attr("aria-label")

# 3) review they wrote
reviews <- html_obj %>% html_nodes(".UD7Dzf") %>% html_text()

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

` ``

1 Ответ

0 голосов
/ 29 октября 2019

Вы можете получить все отзывы в интернет-магазине GooglePlay.

Если вы прокрутите обзоры, вы увидите, что запрос XHR отправляется по адресу:

https://play.google.com/_/PlayStoreUi/data/batchexecute

С формой-данные:

f.req: [[["rYsCDe","[[\"com.playrix.homescapes\",7]]",null,"55"]]]
at: AK6RGVZ3iNlrXreguWd7VvQCzkyn:1572317616250

И параметры:

rpcids=rYsCDe
f.sid=-3951426241423402754
bl=boq_playuiserver_20191023.08_p0
hl=en
authuser=0
soc-app=121
soc-platform=1
soc-device=1
_reqid=839222
rt=c

После игры с различными параметрами я обнаружил, что многие из них необязательны, и запрос можно упростить как:

form-data:

f.req: [[["UsvDTd","[null,null,[2, $sort,[$review_size,null,$page_token]],[$package_name,7]]",null,"generic"]]]

params:

hl=$review_language

Ответ является загадочным, но по сути это данные JSON с разделенными ключами, аналогично protobuf, я написалпарсер ответа, который переводит его в обычный dict объект.

https://gist.github.com/xlrtx/af655f05700eb76bb29aec876493ed90

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...