使用rvest浏览谷歌搜索结果时出现字符(0)错误

使用rvest浏览谷歌搜索结果时出现字符(0)错误,r,web-scraping,rvest,google-search,R,Web Scraping,Rvest,Google Search,我正在努力刮谷歌搜索的标题。但是,无论我尝试使用什么rvest,结果总是返回字符(0) 以下是搜索的代码rstudio: 库(rvest) 图书馆(dplyr) web1% html_text() 标题 我在SelectorGadget中签入的节点名,因此这不应该是问题。我应该如何解决这个问题?也许,我们可以使用: 库(rvest) 图书馆(dplyr) web1%>% html_节点(xpath='//div/div/div/a/div[not(div)])%>% html_文本 输出:

我正在努力刮谷歌搜索的标题。但是,无论我尝试使用什么
rvest
,结果总是返回
字符(0)

以下是搜索的代码
rstudio

库(rvest)
图书馆(dplyr)
web1%
html_text()
标题
我在
SelectorGadget
中签入的节点名,因此这不应该是问题。我应该如何解决这个问题?

也许,我们可以使用:

库(rvest)
图书馆(dplyr)
web1%>%
html_节点(xpath='//div/div/div/a/div[not(div)])%>%
html_文本
输出:

#[1]“rstudio.com”
#[2] “rstudio.cloud”
#[3] “en.wikipedia.org›wiki›RStudio”
# ....

非常感谢您的回答,Akrun!但是你可能知道为什么带有类名(而不是xpath)的初始代码不起作用吗?@AlinaZamaletdinova
class
在google Search中不稳定,以防有人遇到同样的问题,下面是为我工作并返回标题的代码:
library(rvest)library(dplyr)web1%html\u节点(xpath='//div/div/div/a/h3/div[not(div)])%>%html\u text