| browser_dom | R Documentation |
Load an HTML page in a headless browser (Chromium/Chrome/Edge), execute all JavaScript on it, and return (or save) the rendered DOM as HTML.
browser_dom(input, output = NULL, fragment = FALSE, browser = NULL)
input |
Path or URL to the HTML page. |
output |
An optional output file path. If not provided, the rendered HTML is returned as a character string. |
fragment |
Whether to return only the inner body content instead of the full HTML document. |
browser |
Path to the web browser. By default, the browser is found via
|
If output is NULL, the rendered HTML as a character string;
otherwise the output path (invisibly).
f = tempfile(fileext = '.html')
writeLines(c(
'<html><body><div id="out"></div>',
'<script>document.getElementById("out").textContent = "hello";</script>',
'</body></html>'
), f)
xfun::browser_dom(f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.