1

I am trying to connect to google using R but I'm having some issues with the proxy/auth settings. Using VBA all I have to run is the below which works fine:

Function GetResult(url As String) As String
    Dim XMLHTTP As Object, ret As String
    Set XMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.4.0")
    XMLHTTP.Open "GET", url, False
    XMLHTTP.send
    ret = XMLHTTP.responseText
    GetResult = ret
End Function

Sub Example()
    'Print the HTML of Google.com
    Debug.Print GetResult("http://www.google.com")
End Sub

In R, if I run the following:

library('rvest')
url <- 'http://google.com'
webpage <- read_html(url,verbose=TRUE)

I get

Error in open.connection(x, "rb") : 
  Timeout was reached: Connection timed out after 10000 milliseconds

There is an issue with the proxy settings that is being used in R. Is there a way I can figure out what proxy settings VBA is using in excel and use those in R?

user33484
  • 740
  • 2
  • 9
  • 36

1 Answers1

0

Check your proxy settings : https://helpdeskgeek.com/networking/internet-connection-problem-proxy-settings/

Then configure the proxy in R

proxy = paste0("http://",LOGIN,":",PASSWORD,"@,"PROXY_ADRESS,":8080")
Sys.setenv(http_proxy = proxy)
Sys.setenv(https_proxy = proxy)
  • Hi, I am on a corporate machine so those settings are not available to me. I'm hoping I can pull them from VBA somehow – user33484 Jun 13 '19 at 13:14
  • I dont know VBA, but you can get the settings by different ways. Have a look here : https://stackoverflow.com/questions/22368515/how-to-see-the-proxy-settings-on-windows – Alexandre georges Jun 13 '19 at 13:37
  • Thanks, coming out with an AUTH error now instead. My "login" is in the format of "EUROPE\\username" how can I enter that in your format? I think the backslashes are throwing it off somehow. How can I enter it so it uses backslashes? – user33484 Jun 13 '19 at 13:52
  • See here to escape backslashes : https://stackoverflow.com/questions/11806501/how-to-escape-backslashes-in-r-string – Alexandre georges Jun 13 '19 at 15:10