Description Usage Arguments Value Examples
The perform_with_chrome()
function executes an asynchronous Chrome DevTools
Protocol flow with Chromium/Chrome and can turn it into a synchronous function.
An asynchronous remote flow is a function that takes a connection object and
returns a promise.
If several functions are passed to perform_with_chrome()
, their execution is
serial. If one of the asynchronous functions fails, the whole execution also
fails.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
... |
Asynchronous remote flow functions. |
.list |
A list of asynchronous remote flow functions - an alternative to
|
timeouts |
A vector of timeouts applied to each asynchronous function. Repeated. |
cleaning_timeout |
The delay for cleaning Chrome. |
async |
Is the result a promise? Required for using |
bin |
Character scalar, the path to Chromium or Chrome executable.
If not provided, |
debug_port |
Integer scalar, the Chromium/Chrome remote debugging port. |
local |
Logical scalar, indicating whether the local version of the
protocol (embedded in |
extra_args |
Character vector, extra command line arguments passed to Chromium/Chrome. You can know more about command line flags (or switches) from chromium developers |
headless |
Logical scalar, indicating whether Chromium/Chrome is launched in headless mode. |
retry_delay |
Number, delay in seconds between two successive tries to connect to headless Chromium/Chrome. |
max_attempts |
Logical scalar, number of tries to connect to headless Chromium/Chrome. |
An invisible list with the values of the fulfilled promises for each async function.d If there is only async function, the return value is the value of the fulfilled promise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
async_save_as_pdf <- function(url) {
function(client) {
Page <- client$Page
Page$enable() %...>% {
Page$navigate(url = url)
Page$loadEventFired()
} %...>% {
Page$printToPDF()
} %...>% {
write_base64(., paste0(httr::parse_url(url)$hostname, ".pdf"))
}
}
}
save_as_pdf <- function(...) {
list(...) %>%
purrr::map(async_save_as_pdf) %>%
perform_with_chrome(.list = .)
}
save_as_pdf("https://www.r-project.org/", "https://rstudio.com/")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.