curl模拟登陆总结

发布时间:2020-08-03 18:00:12 作者:zhaozhangxiao
来源:网络 阅读:350

<?php

$url = 'http://www.zixue.it/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes';

// $data = 'fastloginfield=email&username=490433117%40qq.com&password=zx199084&quickforward=yes&handlekey=ls';

$data['fastloginfield'] = 'email';

$data['username'] = '490433117@qq.com';

$data['password'] = 'zx199084';

$data['quickforward'] = 'yes';

$data['handlekey'] = 'ls';

$cookie = 'D:\WWW\day1\curl\cookie.txt';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);

curl_exec($ch);


$last_url = 'http://www.zixue.it/thread-12785-1-1.html';

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $last_url);

curl_setopt($curl, CURLOPT_HEADER, 0);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);

$content = curl_exec($curl);

$pattern = '/<dt>最后登录<\/dt><dd>(?P<title>.*?)<\/dd>/is';

if(preg_match($pattern, $content, $matches)){

$title = $matches['title'];

var_dump($title);

echo 'comeOning';

}

要抓取登陆的页面,,安装正常登陆数据格式填写

推荐阅读:
  1. 用php curl请求接口碰到的问题总结
  2. curl 函数总结

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

curl模拟登陆

上一篇:【技术积累】树形结构的循环查找实现案例1

下一篇:HTML5和CSS3扁平化风格博客

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》