Search code examples
urlrhttpwebrequesthttp-headersuser-agent

Changing user agent string in a http request in R


How does one change user agent strings in http requests made in R? And how do I figure out what my current user agent string looks like?

Thanks in advance.


Solution

  • options("HTTPUserAgent") or getOption("HTTPUserAgent") prints your current settings, and options(HTTPUserAgent="My settings") is the way to change it.

    To temporary change this option use: withr::with_options:

    withr::with_options(list(HTTPUserAgent="My settings"), download.file(..something..))
    

    or Droplet answer if you use download.file.