| browser_session | R Documentation |
Start a headless browser (Chromium/Chrome/Edge) once and reuse it to load
pages and evaluate JavaScript on them via the Chrome DevTools Protocol,
instead of starting a new browser for every page as browser_dom() does.
This is much faster for running many checks against different pages.
browser_session(
browser = NULL,
args = browser_args(),
size = NULL,
timeout = 60
)
browser |
Path to the web browser. By default, the browser is found via
|
args |
Command-line arguments passed to the browser, by default
|
size |
The window size, e.g., |
timeout |
The maximum number of seconds to wait for the browser and the
page (when |
A list of functions: open(input, query, wait) loads a page (see
browser_print() for the arguments) and returns the session invisibly;
eval(expr) evaluates JavaScript code on the current page and returns
the value of its last statement as a string; dom() returns the HTML of the current
page; close() closes the browser (it is also closed when the session is
garbage-collected or R exits).
s = xfun::browser_session()
f = tempfile(fileext = ".html")
writeLines('<p id="a">hello</p>', f)
s$open(f)
s$eval('document.getElementById("a").textContent')
s$close()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.