解决方案 »

  1.   

    你的代码没有大问题,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);
      

  2.   

    回楼上wander_wind:谢谢!不过其实我想抓的是晨跑数据,所以就想通过模拟登陆把登录的cookie保存下来,再去这个地址(http://210.35.75.247:8080/student/queryCheckInfo.jsp)抓取晨跑次数。不知道为什么显示登录错误,能请大神再帮我看看吗?麻烦了!谢谢!
      

  3.   

    别客气我也只是菜鸟,一起研究学习下
    首先声明几个名词...
    框架页 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;
      

  4.   

    啊,原来如此,是 http://210.35.75.247:8080/student/studentInfo.jsp 在作怪。已经成功!拜谢!!