Skip to contents

Opens a Chrome with a throwaway profile on the host, lets any browser check run, and downloads url in it; a window stays open until the transfer is done. fetch() does this only when it has to; this is for when the browser is wanted regardless.

Usage

download_in_browser(
  url,
  destfile,
  quiet = FALSE,
  timeout = 3600,
  headed = "auto",
  useragent = TRUE
)

Arguments

url

The file's URL.

destfile

Where to write it. A failed transfer leaves nothing there.

quiet

Suppress progress messages.

timeout

Seconds a transfer in the browser may take.

headed

How to run the browser, when one is needed: "auto", the default, tries headless Chrome first and opens a window only when the headless run does not get through, so that a window is shown only when someone may need to click; TRUE opens a window at once and FALSE never does. Without a display "auto" is headless. A host may run a second check at the file's URL, after the one at its root; headless Chrome has passed such a check with nothing clicked, but only after about two minutes, where a window shows a box that gets it through as soon as it is clicked. "auto" waits those minutes and opens a window if they pass without; TRUE skips the wait.

useragent

The user-agent string the browser announces. Headless Chrome's own calls it HeadlessChrome, and some hosts refuse it on that word alone. TRUE, the default, drops the word, so that the string says the Chrome version and platform it is and nothing it is not; NULL leaves Chrome's own string; a string is used as given. Set before the browser's first request, and what clearance() then reports.

Value

destfile, invisibly. Errors as fetch() does.

Examples

if (FALSE) { # \dontrun{
download_in_browser("https://example.org/large.zip", "large.zip")
} # }