$curlPost ="day=0&jieci9=9&jieci10=10&jxl1=22&Submit=%E6%8F%90%E4%BA%A4";
 
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'http://202.117.1.166:8080/classroom/search.do?method=jxl');//
curl_setopt($ch, CURLOPT_HEADER, 0);//
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//
curl_setopt($ch, CURLOPT_POST, 1);//
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//
curl_close($ch);
print_r($data);//

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>西安交通大学空闲教室查询</title>
    <link href="xjtu_mnews.css" rel="stylesheet" type="text/css" />
    </head><body>
    <div class="header">
    <span><a href="http://m.xjtu.edu.cn"><img src="images/home.png"/></a></span>
    <a href="index.html"><img src="images/logo.gif"/></a></div>
    <div class="weather">
    <p class="left">
    <script language='javaScript'>
    today = new Date();
    function initArray() {
    this.length = initArray.arguments.length;
    for ( var i = 0; i < this.length; i++)
    this[i + 1] = initArray.arguments[i]
    }
    var d = new initArray('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
    var year = (today.getYear()>1000)?today.getYear():today.getYear()+1900;
    document.write(year,'年',today.getMonth()+1,'月',today.getDate(),'日 ',d[today.getDay() + 1]);
    </script>
    </p>
    </div>
    <div align="center" style="margin-top:30px">
    <table align="center">
    <tr>
    <td align="center">
    <a style="text-decoration:none; outline:none" href="search.do?method=xiaoqu&xiaoqu=1">
         <img src="images/xingqing.png"/><br/>兴庆校区</a>
    </td>
    <td align="center">
    <a style="text-decoration:none; outline:none" href="search.do?method=xiaoqu&xiaoqu=2">
         <img src="images/yanta.png"/><br/>雁塔校区</a>
    </td>
    </tr>
    <tr>
    <td colspan="2" height="30px">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><font color="red">* 温馨提示:所有空闲教室数据均从教务处、研究生系统中实时采集</font></td>
    </tr>
    </table>
    </div>
    <div class="copyrightbottom">
    西安交通大学  版权所有<br/>
       西安交通大学网络中心  技术支持
       </div>
    </body>
    </html>
      

  2.   

    本帖最后由 xuzuning 于 2012-11-02 13:24:44 编辑
      

  3.   


    这是不需要注册用户的,任何人都可以查询的,它的提交页面是这个http://202.117.1.166:8080/classroom/search.do?method=xiaoqu&xiaoqu=1,POST的数据是通过httpwatch获得的,不知道是哪里错了,请问下curl还需要考虑些什么,谢谢了
      

  4.   

    $cookiejar = realpath('cookie.txt');
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,'http://202.117.1.166:8080/classroom/search.do?method=xiaoqu&xiaoqu=1');
    curl_setopt($ch, CURLOPT_HEADER, 1);//要取回头
    curl_setopt($ch, CURLOPT_NOBODY, 1);//不要内容
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);//保存cookie
    $data = curl_exec($ch);
    echo $data;//看看头里都有什么
    /*
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Set-Cookie: JSESSIONID=03CF4A3710750F9FBCC9046698055CBB; Path=/classroom
    Content-Type: text/html;charset=UTF-8
    Content-Length: 6546
    Date: Mon, 05 Nov 2012 00:05:16 GMT显然他使用了session做了唯一识别
    并保存了校区信息
    */$curlPost ="day=0&jieci9=9&jieci10=10&jxl1=22&Submit=%E6%8F%90%E4%BA%A4";
     
    curl_setopt($ch,CURLOPT_URL,'http://202.117.1.166:8080/classroom/search.do?method=jxl');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);//要回传cookie
    $data = curl_exec($ch);
    curl_close($ch);
    print_r($data);//于是结果中就有
    /*
    空闲教学楼
    主楼C -- 6间空闲   (点击查看详情) 
    */