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

11,322

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))
Share:
11,322
mikecro
Author by

mikecro

First programmed (in APL) in 1978. Professional programmer for a few years. Now Data Analyst: SQL, R, Excel/VBA

Updated on July 14, 2022

Comments

  • mikecro
    mikecro almost 2 years

    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
    
  • mikecro
    mikecro over 6 years
    agreed. I am guessing that fromJSON isn't based on curl.
  • mikecro
    mikecro over 6 years
    one subtle difference is that fromJSON does not trap on an http error.I am sticking with a try of httr GET followed by fromJSON