使用 模拟登陆 抓取学校系统的晨跑数据,失败了,请教大神 phpcurlcookie 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的代码没有大问题,curl_exec()返回的是结果,你没有接收没有输出,所以空白了刚才试了一下,登陆成功了<?php$url = 'http://210.35.75.247:8080/student/studentFrame.jsp';$name = '1101001';$pw = '1101001';$params = array( 'userName' => $name, 'passwd' => $pw,);$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));$con = curl_exec($ch);curl_close($ch);echo preg_replace('/<frame src="\//Us', '<frame src="http://210.35.75.247:8080/', $con); 回楼上wander_wind:谢谢!不过其实我想抓的是晨跑数据,所以就想通过模拟登陆把登录的cookie保存下来,再去这个地址(http://210.35.75.247:8080/student/queryCheckInfo.jsp)抓取晨跑次数。不知道为什么显示登录错误,能请大神再帮我看看吗?麻烦了!谢谢! 别客气我也只是菜鸟,一起研究学习下首先声明几个名词...框架页 student/studentFrame.jsp 表单提交的action地址学生信息页 student/studentInfo.jsp 是框架页的iframe自动加载的src晨跑成绩 student/queryCheckInfo.jsp用firebug跟踪了一下登陆流程,发现框架页的iframe加载的学生信息后面带了参数?username=...&passwd=....,猜测真正的登陆流程应该在学生信息页。我把登陆失败的页面不echo保存在文件中看了下,框架页的html和登陆成功几乎相同,只是多了一段跳转js。利用学生信息页的JSESSIONID登陆成功了,和框架页的对比下,不一样。蛋疼的管理系统<?php$url1 = 'http://210.35.75.247:8080/student/studentInfo.jsp';$url2 = 'http://210.35.75.247:8080/student/queryCheckInfo.jsp';$name = '1101001';$pw = '1101001';$params = array( 'userName' => $name, 'passwd' => $pw,);$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url1 . '?' . http_build_query($params));curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);$con = curl_exec($ch);preg_match('/Set-Cookie: (.*);/Us', $con, $match);$cookie = $match[1];curl_setopt($ch, CURLOPT_URL, $url2);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_COOKIE, $cookie);$con = curl_exec($ch);curl_close($ch);echo $con; 啊,原来如此,是 http://210.35.75.247:8080/student/studentInfo.jsp 在作怪。已经成功!拜谢!! apache rewrite规则 跪求大神救命啊 高手帮忙输出一下这个数组吧.头痛死了. 请了个教~服务器的数据支持 dreamweaver 怎样设置站点 帮忙推荐一套php的运行环境的下载地址,要中文版的!急! php怎样替换掉所有空格 如何对网站目录进行操作(php) 向其他的页面提交数据 关于框架页的问题 分割中文字符如何避免切割半个中文字符? c++怎么调用PHP的函数 怎么封装
刚才试了一下,登陆成功了<?php$url = 'http://210.35.75.247:8080/student/studentFrame.jsp';
$name = '1101001';
$pw = '1101001';
$params = array(
'userName' => $name,
'passwd' => $pw,
);$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$con = curl_exec($ch);
curl_close($ch);echo preg_replace('/<frame src="\//Us', '<frame src="http://210.35.75.247:8080/', $con);
首先声明几个名词...
框架页 student/studentFrame.jsp 表单提交的action地址
学生信息页 student/studentInfo.jsp 是框架页的iframe自动加载的src
晨跑成绩 student/queryCheckInfo.jsp
用firebug跟踪了一下登陆流程,发现框架页的iframe加载的学生信息后面带了参数?username=...&passwd=....,猜测真正的登陆流程应该在学生信息页。我把登陆失败的页面不echo保存在文件中看了下,框架页的html和登陆成功几乎相同,只是多了一段跳转js。利用学生信息页的JSESSIONID登陆成功了,和框架页的对比下,不一样。蛋疼的管理系统
<?php$url1 = 'http://210.35.75.247:8080/student/studentInfo.jsp';
$url2 = 'http://210.35.75.247:8080/student/queryCheckInfo.jsp';
$name = '1101001';
$pw = '1101001';
$params = array(
'userName' => $name,
'passwd' => $pw,
);$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url1 . '?' . http_build_query($params));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$con = curl_exec($ch);preg_match('/Set-Cookie: (.*);/Us', $con, $match);
$cookie = $match[1];curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
$con = curl_exec($ch);
curl_close($ch);echo $con;