Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy setting for R

Tags:

r

I am facing problem while conecting R with internet in my office. May be this due to LAN settings. I tried the almost all possible ways I come across in the web (see below) but still in vain.

  • Method1: Invoking R using --internet2

  • Method2: Invoking R by setting ~/Rgui.exe http_proxy=http:/999.99.99.99:8080/ http_proxy_user=ask

  • Method3: Setting Setinternet2=TRUE

  • Method4:

    curl <- getCurlHandle() curlSetOpt(.opts = list(proxy = '999.99.99.99:8080'), curl = curl) Res <- getURL('http://www.cricinfo.com', curl = curl) 

In above all methods I can able to load packages directly from CRAN also able to download files using download.file command

But using getURL(RCurl), readHTMLTable(XML), htmlTreeParse(XML) commands I am unable to extract web data. I am getting ~<HEAD>\n<TITLE>Access Denied</TITLE>\n</HEAD>~ error.

How to set LAN proxy settings for XML package in R?

like image 603
AVSuresh Avatar asked Jun 24 '11 11:06

AVSuresh


People also ask

What is proxy R?

proxy: Distance and Similarity Measures Provides an extensible framework for the efficient calculation of auto- and cross-proximities, along with implementations of the most popular ones. Version: 0.4-27. Depends: R (≥ 3.4.0)

What does proxy mean in it?

A proxy server is a computer system or router that functions as a relay between client and server. It helps prevent an attacker from invading a private network and is one of several tools used to build a firewall. The word proxy means "to act on behalf of another," and a proxy server acts on behalf of the user.


2 Answers

On Mac OS, I found the best solution here. Quoting the author, two simple steps are:

1) Open Terminal and do the following:

export http_proxy=http://staff-proxy.ul.ie:8080 export HTTP_PROXY=http://staff-proxy.ul.ie:8080 

2) Run R and do the following:

Sys.setenv(http_proxy="http://staff-proxy.ul.ie:8080") 

double-check this with:

Sys.getenv("http_proxy") 

I am behind university proxy, and this solution worked perfectly. The major issue is to export the items in Terminal before running R, both in upper- and lower-case.

like image 166
Geek On Acid Avatar answered Oct 05 '22 08:10

Geek On Acid


The problem is with your curl options – the RCurl package doesn't seem to use internet2.dll. You need to specify the port separately, and will probably need to give your user login details as network credentials, e.g.,

opts <- list(   proxy         = "999.999.999.999",    proxyusername = "mydomain\\myusername",    proxypassword = "mypassword",    proxyport     = 8080 ) getURL("http://stackoverflow.com", .opts = opts) 

Remember to escape any backslashes in your password. You may also need to wrap the URL in a call to curlEscape.

like image 23
Richie Cotton Avatar answered Oct 05 '22 07:10

Richie Cotton