PHP使用curl模拟用户登陆
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://cc.cmbchina.com/promotion/20150401_app.htm');
curl_setopt($ch, CURLOPT_POST, 1);
$request = 'email_address=&password=&action=';
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
//把返回来的cookie信息保存在$cookie_jar文件中
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
//设定返回的数据是否自动显示
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//设定是否显示头信息
curl_setopt($ch, CURLOPT_HEADER, false);
//设定是否输出页面内容
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_exec($ch);
curl_close($ch);
//get data after login
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, 'http://cc.cmbchina.com/promotion/20150401_app.htm');
curl_setopt($ch2, CURLOPT_HEADER, false);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie_jar);
$orders = curl_exec($ch2);
echo '<pre>';
echo strip_tags($orders);
echo '</pre>';
curl_close($ch2);
[/code]