curl模拟登陆总结-创新互联
$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 = '/
if(preg_match($pattern, $content, $matches)){
$title = $matches['title'];
var_dump($title);
echo 'comeOning';
}
要抓取登陆的页面,,安装正常登陆数据格式填写
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
本文标题:curl模拟登陆总结-创新互联
网站网址:http://scjbc.cn/article/dcjhcs.html