R Language Configuration for the Proxy
If you use the open-source R statistical programing language, you can configure it to carry out HTTP or HTTPS proxy requests. R has distributions that can be run in Windows, Linux, and Mac.
You'll need to point to the proxy by adding one or more environment variables to your installation. Add the environment variables to the R environment file.
- On RStudio Server, the filepath is
R_HOME/etc/Renviron.site
. - On RStudio Desktop, the filepath in the user home directory is
~/.Renviron
. - Access your .Renviron file by running the command
file.edit('~/.Renviron')
in RStudio.
If these files don't exist in the default installation of R, you'll need to create them.
http_proxy=http://proxy.dom.com/ http_proxy_user=user:passwd https_proxy=http://proxy.dom.com/ https_proxy_user=user:passwd
Tips
- Note that HTTPS requests require extra work to make use of custom headers.
- The R package "RCurl" provides more comprehensive facilities to download data from URLs.
- Configuring R to Use an HTTP or HTTPS Proxy: Includes links to related articles from R Studio.
- Download File from the Internet : Documentation for an R language method which includes guidance on Linux and Windows, and methods for cURL, libcurl, and Wget.
- Running RStudio Server with a Proxy: A range of traffic-handling configurations for running RStudio Server behind a proxy.
- Proxy setting for R: A troubleshooting forum that addresses several issues related to R with proxies.
R with Web Browsers
For web browsers, you must use IP address authentication, then configure your network proxy settings. If you use Firefox or Chrome, the FoxyProxy plugin makes it very easy to configure your proxy settings.
For testing, the article referenced above, How to drive a Web browser with R (and RSelenium), includes detail on how to set up R Studio to open several different browsers in succession.
R and Selenium
For automated testing, the R Studio provides a link to install the Selenium 2.0 WebDriver. Here is a link to a general how-to: How to drive a Web browser with R (and RSelenium).
The "RSelenium" package, with a complete set of R language bindings for Selenium WebDriver 2.0, is available as a PDF.
Scraping with Selenium discusses a variety of ways R and Selenium can be used together with a proxy.