基于PHP的cURL类的模拟登陆
2016-05-14 13:57
447 查看
<div id="form"> <form method="post" action="transfer.php/" enctype="multipart/form-data" name="form1" id="form1"> <textarea style="width: 50%" name="code" id="code" rows="17" onfocus="textfocus()" onblur="textblur()">请输入:</textarea><br /> </form></div>
<?php sleep(1); $re=$_REQUEST["code"]; $receive =stripslashes($re); $data = array( 'code' => $receive, 'simplot' => 'Run the code' ); //$post_data= http_build_query($data); $post_data= http_build_query($data); $url = "http://www.example.com/"; $cookie_file = tempnam('./temp','cookie'); // 参数数组 $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $url); curl_setopt ( $ch, CURLOPT_HEADER, 1); curl_setopt ( $ch, CURLOPT_POST, 1 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ($ch, CURLOPT_POSTFIELDS,$post_data); curl_setopt ($ch, CURLOPT_TIMEOUT,10); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_exec ( $ch ); curl_close ( $ch ); $ch1 = curl_init($url); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_COOKIEFILE, $cookie_file); $contents = curl_exec($ch1); curl_close($ch1); preg_match("/>(.*)<\/p>/",$contents,$arr); echo $arr[0]; fclose($temp); ?>
相关文章推荐
- Matplotlib 简单画图
- <转>thinkphp自动验证无效的问题
- PHP failed to ptrace(PEEKDATA) pid 1918: Input/output error (5) 解决
- FragmentPagerAdapter与FragmentStatePagerAdapter区别
- 通过ContentProvider播放音乐文件
- [PHP] 重回基础(IO流)
- PhpStorm许可server地址
- PHP设计模式:观察者模式
- PHP之:PHP编程效率的20个要点
- thinkphp的model模型的设计经验总结
- thinkphp的model模型的设计经验总结
- thinkphp的model模型的设计经验总结
- thinkphp的目录结构设计经验总结
- thinkphp的目录结构设计经验总结
- thinkphp的目录结构设计经验总结
- 总结thinkphp快捷查询getBy、getField、getFieldBy用法及场景
- 总结thinkphp快捷查询getBy、getField、getFieldBy用法及场景
- 总结thinkphp快捷查询getBy、getField、getFieldBy用法及场景
- php中使用addslashes函数报错问题的解决方法
- php第十九节课