1

I am having trouble trying to retrieve the gzip'd content of the following URL:

https://www.lendingclub.com/browse/browseNotesAj.action?method=getResultsInitial&startindex=0&pagesize=1

I can see that the content is encoded using gzip by looking at the response headers:

HTTP/1.1 200 OK
Content-Encoding: gzip

I have tried RCurl using getURL as well as this post with no luck. Can someone help me try to get the content into a variable (hopefully without requiring writing and reading from file)?

Community
  • 1
  • 1
John Richardson
  • 676
  • 8
  • 24

2 Answers2

3

Or in httr

library(httr)
library(jsonlite)
out <- GET("https://www.lendingclub.com/browse/browseNotesAj.action?method=getResultsInitial&startindex=0&pagesize=1")
jsonlite::fromJSON(content(out, "text"))
$result
[1] "success"

$searchresult
$searchresult$loans
loanGrade            purpose loanAmtRemaining loanUnfundedAmount noFee primeTotalInvestment                    title
1        C5 debt_consolidation               25                 25     0                    0 Debt consolidation
  isInCurrentOrder alreadySelected primeFractions    fico wholeLoanTimeRemaining loanType primeUnfundedAmount
1            FALSE           FALSE              0 720-724                 -69999 Personal                   0
  hasCosigner amountToInvest loan_status alreadyInvestedIn loanLength searchrank loanRateDiff loanGUID
1       FALSE              0   INFUNDING             FALSE         36          1          .00 35783459
  isWholeLoan loanAmt loanAmountRequested primeMarkedInvestment loanRate loanTimeRemaining
1           0    7650                7650                     0    14.99        1199721001

$searchresult$totalRecords
[1] 1472
sckott
  • 5,755
  • 2
  • 26
  • 42
2

Turns out RCurl handles gzip encoding:

getURL('https://www.lendingclub.com/browse/browseNotesAj.action?method=getResultsInitial&startindex=0&pagesize=1', 
       encoding="gzip")
Thomas
  • 43,637
  • 12
  • 109
  • 140
John Richardson
  • 676
  • 8
  • 24