Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有R:xpath问题的Web抓取应用程序评论_R_Xpath_Web Scraping - Fatal编程技术网

带有R:xpath问题的Web抓取应用程序评论

带有R:xpath问题的Web抓取应用程序评论,r,xpath,web-scraping,R,Xpath,Web Scraping,我试图从play和应用商店(应用程序名称、评级、全文评论、用户名)中获取应用程序评论,但遇到了一些问题。我读了这篇文章,但在使用硒元素时遇到了很多困难,所以我想知道我是否可以用一种更简单的方法来做。使用XPath时,我能够获得应用程序的名称,但不能获得评论文本或评分。我将为用户获取“字符(0)”并查看数据。我的另一个问题是,在Play Store上要查看更多评论,您必须单击Read more,我想知道是否会在页面上加载的内容时停止抓取,如果是,如何获得完整的评论集 在今天之前我没有抓取网页的经验

我试图从play和应用商店(应用程序名称、评级、全文评论、用户名)中获取应用程序评论,但遇到了一些问题。我读了这篇文章,但在使用硒元素时遇到了很多困难,所以我想知道我是否可以用一种更简单的方法来做。使用XPath时,我能够获得应用程序的名称,但不能获得评论文本或评分。我将为用户获取“字符(0)”并查看数据。我的另一个问题是,在Play Store上要查看更多评论,您必须单击Read more,我想知道是否会在页面上加载的内容时停止抓取,如果是,如何获得完整的评论集

在今天之前我没有抓取网页的经验,如果这是显而易见的,我很抱歉

library(rvest)
library(RSelenium) 
library(xml2)
library(stringr)

url <- 'https://play.google.com/store/apps/details?id=com.woebot&hl=en_US'

webpage <- read_html(url)
Name_data_html <- webpage %>% html_nodes(xpath='/html/body/div[1]/div[4]/c-wiz/div/div[2]/div/div[1]/div/c-wiz[1]/c-wiz[1]/div/div[2]/div/div[1]/c-wiz[1]/h1/span')
Name_data <- html_text(Name_data_html)
head(Name_data)


User_data_html <- webpage %>% html_nodes(xpath='/html/body/div[1]/div[4]/c-wiz[3]/div/div[2]/div/div[1]/div/div/div[1]/div[2]/div/div[2]/div[1]/div[1]/span')
User_data <- html_text(User_data_html)
head(User_data)

Review_data_html <- webpage %>% html_nodes(xpath='/html/body/div[1]/div[4]/c-wiz[3]/div/div[2]/div/div[1]/div/div/div[1]/div[2]/div/div[2]/div[2]')
Review_data <- html_text(Review_data_html)
head(Review_data)

product_data <- data.frame(Name = Name_Data, User = User_data,Review=Review_data)
str(product_data)
库(rvest)
图书馆(资源库)
库(xml2)
图书馆(stringr)

url您已经调用了RSelenium,但您正在使用rvest命令。如果您试图抓取的网站字段不是使用javascript生成的,那么这些功能就可以正常工作,但这里的情况并非如此