提供几篇文章仅供参考:
http://blog.csdn.net/wusuopuBUPT/article/category/1371528/4
curl模拟登陆获取cookie(无法验证程序的正确性,因为没有学号)
http://blog.csdn.net/crazy__chen/article/details/24311141
CURL模拟登陆并发帖(已试,失败)
http://blog.csdn.net/enough_br/article/details/8565587
php100教程第88课:模拟登陆(已试,失败)
http://www.php100.com/html/shipinjiaocheng/PHP100shipinjiaocheng/2010/0628/4848.html
1、CURL模拟登陆的流程和步骤
2、tempnam 创建一个临时文件
3、使用CURL模拟登陆到PHP100论坛
<?php
$cookie_file = tempnam('./temp','cookie');
$login_url = 'http://bbs.php100.com/login.php';
$post_fields = 'cktime=31536000&step=2&pwuser=php100-88&pwpwd=111111';
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);
$url='http://bbs.php100.com/userpay.php';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);
preg_match("/<li> (.*)<\/li>/",$contents,$arr);
echo $arr[1];
curl_close($ch);
?>
模拟登陆一直不能成功,不知道原因出在哪里,感觉程序没有错误,可能对原理理解不够,或者现在的网站都会屏蔽这种方法。。。。。。。。。