Opens a Chrome on the host, lets any check run, and returns the browser's
user-agent string and cookies, which clearance_handle() puts on a curl
request. Whether the server then serves curl is the server's call: after
a block page it usually does not, since the rule is about the client, and
fetch() then downloads in the browser instead. Clearances are cached per
host for the R session.
Usage
clearance(
url,
refresh = FALSE,
quiet = FALSE,
wait = NULL,
headed = "auto",
useragent = TRUE
)Arguments
- url
The file's URL.
- refresh
Get a new clearance even when one is cached.
- quiet
Suppress progress messages.
- wait
Seconds to wait for the check to pass: by default two minutes with a window, so that a person can click, and thirty seconds headless.
- headed
How to run the browser when one is needed.
"auto", the default, runs headless and opens a window only when the headless run ends on a check or a block and there is a display to show it on;TRUEopens a window at once;FALSEnever does. A second check, at the file's URL, takes headless Chrome about two minutes to pass unclicked, where a window is through as soon as its box is clicked:"auto"waits those minutes before opening a window,TRUEskips the wait.- useragent
The browser's user-agent string.
TRUE, the default, drops the wordHeadlessfrom Chrome's own string, which some hosts refuse on that word alone, and changes nothing else;NULLleaves Chrome's own; a string is used as given.
Value
A safeconduct_clearance: a list with host, useragent,
cookie (one Cookie: header value) and time. Errors as fetch()'s.
Examples
if (FALSE) { # \dontrun{
cl <- clearance("https://www12.statcan.gc.ca/")
curl::curl_fetch_memory("https://www12.statcan.gc.ca/", clearance_handle(cl))
} # }
