英文:
Is it possible to include a JavaScript library with chromote?
问题
使用 phantomJS 可以通过 page.inject("thelibrary.js") 来包含一个 JavaScript 库。chromote 包是否也可以实现这个功能?我在文档中没有找到相关信息。
英文:
With phantomJS one can include a JavaScript library by doing page.inject("thelibrary.js"). Is it possible with the chromote package? I didn't find anything in the doc.
答案1
得分: 0
      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)
英文:
One can do
      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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论