在 R 中将 HTML/CSS 转换为图像(png 或任何无损格式)

Convert HTML/CSS to image (png, or any loseless format) in R

我想在 R 中编写一段代码,获取 HTML/CSS 页面并为其拍照。我没有在 R 中找到任何使这个过程变得简单的包。

我找到了 wkhtmltopdf,但它会将 HTML 转换为 PDF,然后我必须将其另存为图像。

你有没有找到任何方法来做到这一点,最好是在 R 中?

您可以使用 rselenium。 看看https://cran.r-project.org/web/packages/RSelenium/vignettes/RSelenium-basics.html

require(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost" 
                      , port = 4444
                      , browserName = "firefox"
                      )
remDr$open()
remDr$navigate("http://www.r-project.org/")
remDr$maxWindowSize()
remDr$screenshot(display = TRUE)

这个例子取自那里