我尝试使用 curl 登录我的银行。在涉及到 cookie(由 javascript 设置)之前,这一切都很好。这是我要发送的表格(凭据是假的):
<form method="post" action="https://www.icabanken.se/Secure/Login/LoginVerify.aspx">
<input type="hidden" name="pnr" value="8502191714" />
<input type="hidden" name="JSEnabled" value="1" />
<input type="hidden" name="OBAS" value="" />
<input type="hidden" name="refurl" value="" />
<input type="hidden" name="refurlrequiressigning" value="False" />
<input type="password" class="typetext" name="Password" id="PasswordSimple" maxlength="4" value="1111" />
<input class="button-image button-small" type="submit" id="LoginSimplifiedButton" value="Logga in" />
</form>
使用以下 PHP / CURL 代码:
enter codssde here
$post_data['pnr'] = '8502191714';
$post_data['password'] = '1111';
$post_data['JSEnabled'] = '1';
$post_data['OBAS'] ='';
$post_data['refurlrequiressigning'] = '';
$post_data['refurl'] = '';
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
$post_array = implode ('&', $post_items);
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_CERTINFO, 1);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 1000000);
//COOKIES
$Cookiefile='C:\wamp\www\Project1\gcookies.txt';
curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookiefile);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $Cookiefile);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
curl_setopt($ch, CURLOPT_URL,'https://www.icabanken.se/Secure/Login/LoginVerify.aspx');
$data = curl_exec($ch);
echo $data;
我得到的响应是“您的浏览器不支持 cookie”。有什么巧妙的解决方案可以解决这个问题吗?