php 模拟登陆

提供几篇文章仅供参考:


一个CURL模拟登陆论坛的脚本+cookie伪造的方法

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);
?>


模拟登陆一直不能成功,不知道原因出在哪里,感觉程序没有错误,可能对原理理解不够,或者现在的网站都会屏蔽这种方法。。。。。。。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值