Php 借贷俱乐部网站不允许我通过CURL登录

Php 借贷俱乐部网站不允许我通过CURL登录,php,curl,Php,Curl,我正试图从贷款俱乐部下载贷款统计文件。他们提供文件的两个版本:安全版本和常规版本。为了下载安全版本,我必须登录 url的内容类似于: 每次我登录并浏览页面时,“签名”和“发布”似乎都会发生变化 我的解决方案是登录到该站点,转到下载页面并使用查询字符串获取完整的url 我尝试使用以下代码登录: $username = "myemail@example.com"; $password = "mypassword"; $url='https://www.lendingclub.com/accoun

我正试图从贷款俱乐部下载贷款统计文件。他们提供文件的两个版本:安全版本和常规版本。为了下载安全版本,我必须登录

url的内容类似于:

每次我登录并浏览页面时,“签名”和“发布”似乎都会发生变化

我的解决方案是登录到该站点,转到下载页面并使用查询字符串获取完整的url

我尝试使用以下代码登录:

$username = "myemail@example.com";
$password = "mypassword";

$url='https://www.lendingclub.com/account/login.action?login_email='.$username.'&login_password='.$password;
$agent= 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36';

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
$httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE);

var_dump($httpcode);
var_dump($result);
return;
我得到了200的http响应。及

int(200) string(32454) "    
This website does not support this version of Internet Explorer. Please upgrade to the latest version for a better experience. Upgrade Now
...
当我在浏览器中访问网站时,我通过嗅探标题获取用户代理字符串

我花了一下午的大部分时间在谷歌上搜索,试图找到解决这个问题的方法。我试着吃饼干,但没用

还有什么我可以试试的吗


谢谢。

在尝试了更多的东西之后,我终于找到了解决问题的方法

我将其张贴在此处,以备将来有人遇到类似问题时参考:

在第一次请求中,我试图使用我的登录凭证(用户名和密码)登录到Lending Club。该网站不允许我登录,并不断将我重定向到登录屏幕

我的解决方案是使用2个cURL请求。第一个进入登录页面的用户没有我的凭据。我这样做是为了保存站点设置的cookie。然后,我在第二个cURL请求中使用了cookie——这是一个带有登录凭据的请求。成功了

请参见以下工作代码:

$cookie = 'cookie.txt';
$url = 'https://www.lendingclub.com/account/login.action';

//first cURL request - no login credentials. Used only to get the cookie from site.
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); // Stores cookies in the temp file 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$output = curl_exec($ch);

//second cURL request - with login credentials. Added cookie obtained from first cURL request above.
$fields = array( 
    'login_email' => 'email@example.com', 
    'login_password' => 'mypassword', 
);
$fields_string = ''; 
foreach($fields as $key=>$value)
{ 
    $fields_string .= $key . '=' . $value . '&'; 
}
rtrim($fields_string, '&'); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, count($fields)); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); //Uses cookies from the temp file 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); // Stores cookies in the temp file 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Tells cURL to follow redirects 
$output = curl_exec($ch);
此外,我仍然收到消息,该网站不支持此版本的Internet Explorer。但这似乎只是一个警告。我仍然可以登录


谢谢。

对你正在做/已经做的事情感兴趣。我正在使用java开发类似的东西。我很想和你聊天。