我想模拟登陆正方教务系统,但一直不成功,代码如下<?php$url_yzm= 'http://61.139.105.138/CheckCode.aspx';
$fp = fopen("CheckCode.gif","wb");   //验证码文件
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url_yzm);
curl_setopt($curl, CURLOPT_HEADER, 0);    //不读取http头,因为只要得到图片数据即可。
curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt");                  //保存cookie
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie.txt");                   //读取cookie
$data = curl_exec($curl);        //得到图片数据
fwrite($fp, $data);       //保存
fclose($fp);$post_data= array (
    "txtUserName" => "11041050121",
    // 要上传的本地文件地址
    "TextBox2" => "zy794006157",
    "txtSecretCode" => $data,
    "RadioButtonList1" => "学生",
    "hidsc" => "",
    "hidPdrs" => "",
    "Button1" => "登陆",
    "Button2" => "",
    "lbLanguage" => ""
);$ch = curl_init();
$cookie_jar = tempnam('./tmp','cookie'); 
curl_setopt($ch, CURLOPT_URL,'http://61.139.105.138/default2.aspx'); //地址
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_NOBODY, false); 
$out = curl_exec($ch); 
curl_close($ch); $ch0 = curl_init();
$url = "http://61.139.105.138/xs_main.aspx?xh=".$post_data['txtUserName'];
curl_setopt($ch0, CURLOPT_URL,$url); 
curl_setopt($ch0, CURLOPT_HEADER, 0); 
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch0, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch0, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5');curl_setopt($ch0, CURLOPT_COOKIEFILE, $cookie_jar); 
$orders = curl_exec($ch0); 
echo $orders;?>
教务系统地址<a href="http://61.139.105.138/default2.aspx">地址</a>,希望指点一下

解决方案 »

  1.   

    <form name="form1" method="post" action="default2.aspx" id="form1">
    <input type="hidden" name="__VIEWSTATE" value="dDwyODE2NTM0OTg7Oz6shNeipJEfI7v6zFdyrUQ/5qlltg==" />
    <div class="login_main">
    <div class="login_logo"><h2><img src="logo/logo_school.png"></h2>
    <h3><img src="logo/logo_jw.png"></h3>
    </div>
    <div class="login_left"><img class="login_pic" src="logo/login_pic.png"></div>
    <div class="login_right">
    <dl style="MARGIN-TOP:92px">
    <dt class="uesr">
    <label id="lbYhm">Óû§Ãû£º</label>
    </dt>
    <dd>
    <input name="txtUserName" type="text" id="txtUserName" tabindex="1" class="text_nor" />
    </dd>
    </dl>
    <div style="CLEAR:both"></div>
    <dl>
    <dt class="passw">
    <label id="lbMm">ÃÜ¡¡Â룺</label>
    </dt>
    <dd>
    <input name="TextBox2" type="password" id="TextBox2" tabindex="2" class="text_nor" />
    </dd>
    </dl>
    <div style="CLEAR:both"></div>
    <dl style="POSITION:relative">
    <dt class="yzm">
    <label id="lbYzm">ÑéÖ¤Â룺</label>
    </dt>
    <dd>
    <!--position:absolute;top:0px;left:68px;Width:64px;height:18px;line-height:18px;padding:1px 2px;-->
    <input name="txtSecretCode" type="text" id="txtSecretCode" tabindex="3" class="text_nor" alt="¿´²»Ç壬»»Ò»ÕÅ" title="¿´²»Ç壬»»Ò»ÕÅ" onfocus="show(this);" onkeydown="keydown(this);" onblur="yzblur(this);" style="PADDING-BOTTOM:1px;LINE-HEIGHT:18px;PADDING-LEFT:2px;PADDING-RIGHT:2px;COLOR:#92a4bf;FONT-SIZE:14px;PADDING-TOP:1px" />
    <img id="icode" src="CheckCode.aspx" onclick="reloadcode();" alt="¿´²»Ç壬»»Ò»ÕÅ" title="¿´²»Ç壬»»Ò»ÕÅ" alt="" border="0" style="POSITION:absolute;TOP:5px;LEFT:130px" />
    <a id="icodems" onclick="reloadcode();" style="POSITION:absolute;LINE-HEIGHT:14px;WORD-WRAP:break-word;COLOR:blue;WORD-BREAK:break-all;TOP:5px;CURSOR:pointer;LEFT:210px">¿´²»Çå»»Ò»ÕÅ</a>
    </dd>
    <dt></dt>
    </dl>
    <div style="CLEAR:both"></div>
    <dl>
    <dd>
    <table id="RadioButtonList1" border="0">
    <tr>
    <td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="²¿ÃÅ" tabindex="4" /><label for="RadioButtonList1_0">²¿ÃÅ</label></td><td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="½Ìʦ" tabindex="4" /><label for="RadioButtonList1_1">½Ìʦ</label></td><td><input id="RadioButtonList1_2" type="radio" name="RadioButtonList1" value="ѧÉú" checked="checked" tabindex="4" /><label for="RadioButtonList1_2">ѧÉú</label></td><td><input id="RadioButtonList1_3" type="radio" name="RadioButtonList1" value="·Ã¿Í" tabindex="4" /><label for="RadioButtonList1_3">·Ã¿Í</label></td>
    </tr>
    </table></dd>
    <dt></dt>
    </dl>
    <div style="CLEAR:both"></div>
    <dl>
    <dd>
    <input type="submit" name="Button1" value="" id="Button1" class="btn_dl" />
    <input type="submit" name="Button2" value="" id="Button2" class="btn_cz" onclick="window.close();return false;" />
    <input name="lbLanguage" type="text" id="lbLanguage" style="DISPLAY: none" />
    <p><br>
    <A style="DISPLAY: none" href="xsxjxtdl.aspx" target="_blank">
    <span id="lbSelect">ѧÉúѧ¼®ÐÅÏ¢²éѯϵͳ</span></A></p>
    </dd>
    </dl>
    </div>
    <div class="login_copyright">
    <span>&copy;1999-2012  <a href="http://www.zfsoft.com" target="_blank">Õý·½Èí¼þ¹É·ÝÓÐÏÞ¹«Ë¾</a> <span>°æȨËùÓÐ</span>&nbsp;&nbsp;ÁªÏµµç»°£º0571-89902828</span>
    <input name="hidPdrs" id="hidPdrs" type="hidden" size="5" /><input name="hidsc" id="hidsc" type="hidden" size="5" />
    </div>
    </div>
    </form>
    表单内容,不知道该传的值都有没有传完
      

  2.   

    正在学习这个,curl很强大。
      

  3.   

    php的正方爬虫库在这里:https://github.com/Cheukfung/ZFCrawler