Gzip编码的内容URL

时间:2014-11-17 01:30:46

标签: r rcurl

我无法尝试检索以下网址的gzip内容:

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

我可以看到内容是通过查看响应标头使用gzip编码的:

HTTP/1.1 200 OK
Content-Encoding: gzip

我使用getURL以及此post尝试了RCurl而没有运气。有人可以帮我尝试将内容变成变量(希望不需要写文件和从文件中读取)吗?

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:2)

结果RCurl处理gzip编码:

getURL('https://www.lendingclub.com/browse/browseNotesAj.action?method=getResultsInitial&startindex=0&pagesize=1', 
       encoding="gzip")