在Mac上但在Debian上使用rvest和V8的R脚本

问题描述

我有这个脚本,可以在Rstudio的Mac上完美运行。但是,如果我尝试在Debian或docker中运行它,则会出现此错误

Error in context_eval(join(src),private$context,serialize) :
  ReferenceError: window is not defined
Calls: <Anonymous> ... <Anonymous> -> evaluate_js -> get_str_output -> context_eval

脚本

library(rvest) 
library(dplyr)
library(V8)

ctx <- v8(global="window")

page <- read_html('https://finance.yahoo.com/quote/WORK') 
js <- html_nodes(page,"script")[60] %>% 
  html_text() %>% 
  stri_replace_first_fixed("(function (root) {","var root = { App : {}};\n") %>% 
  stri_replace_last_fixed("}(this));","")


ctx$eval(JS(js))
slaper <- ctx$get('root',flatten=TRUE)

不知道要做什么

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)