一个很简单的问题,我很惊讶地找不到任何答案:你怎么才能同意网站上的cookie。
我运行的代码如下:
require(rvest)
finances <- "https://finance.yahoo.com/quote/MSFT/financials?p=MSFT&_guc_consent_skip=1608408673"
finances <- read_html(finances)
finances <- html_table(finances,header = TRUE)这给出了一个空的data.frame,我怀疑这是因为网站要求同意跟踪cookies。如何使用rvest同意这样的cookie?
发布于 2020-12-20 20:52:03
与我回答的this question类似,我将给出从表中获取数据的代码:
library(rvest)
library(V8)
pg <- read_html("https://finance.yahoo.com/quote/MSFT/financials?p=MSFT&_guc_consent_skip=1608408673")
js <- pg %>% html_node(xpath = "//script[contains(., 'root.App.main')]") %>% html_text()
ct <- new_context()
ct$eval(js)
data <- ct$get("App")
incomeStatementHistory <- data$main$context$dispatcher$stores$QuoteSummaryStore$incomeStatementHistory
incomeStatementHistoryQuarterly <- data$main$context$dispatcher$stores$QuoteSummaryStore$incomeStatementHistoryQuarterlyhttps://stackoverflow.com/questions/65374044
复制相似问题