使用
phantomJS
可以通过执行 page.inject("thelibrary.js")
来包含 JavaScript 库。可以使用 chromote 包吗?我在文档中没有找到任何内容。
一个人就能做到
chrm <- Chrome$new(
path = chromePath,
args = "--disable-gpu --headless --remote-debugging-port=9222"
)
chromote <- Chromote$new(browser = chrm)
session <- ChromoteSession$new(parent = chromote)
ids <- session$Page$navigate("about:blank")
jsfile <- "path/to/jslibrary"
library <- paste0(readLines(jsfile), collapse = "\n")
. <- session$Runtime$evaluate(library)