R - Error when using getURL from curl after site was changed

mikecro picture mikecro · May 8, 2017 · Viewed 8.1k times · Source

I have been using getURL from curl (in R) to read from https://fantasy.premierleague.com/drf/bootstrap-static

Example code: print(getURL("https://fantasy.premierleague.com/drf/bootstrap-static"))

No problem until a few days ago. But now getting the error:

Error in function (type, msg, asError = TRUE)  : 
  error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

Have upgraded to latest R (3.4.0) and curl package: RCurl_1.95-4.8

I have a workaround (to use GET from httr) but can anyone help me get it working with getURL?

I believe the server change is that they only now support TLS 1.2. I have tried the following to fix but now get a new error. May relate to needing newer OpenSSL?

CURL_SSLVERSION_TLSv1_2 <- 6L
opt <- RCurl::curlOptions(verbose = TRUE, sslversion = 
CURL_SSLVERSION_TLSv1_2)
print( RCurl::getURL("https://fantasy.premierleague.com/drf/bootstrap-static", .opts = opt))

New error is:

Unsupported SSL protocol version

Answer

user1966593 picture user1966593 · Aug 2, 2017

I think if you remove the getURL part of the code it should work ok

url = "https://fantasy.premierleague.com/drf/bootstrap-static"
json = fromJSON((url))