http://www.33591.com/userlogin.aspx这个网站太复杂了,如何用webrequest模拟登录啊?

解决方案 »

  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="X-UA-Compatible" content="IE=EmulateIE7" >
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="缘分博客,在线音乐,在线视频,在线游戏,交友平台,33591.com欢迎您,Fate blog, online music, online video, online games, dating platform, 33591.com Welcome" name="keywords">
    <meta content="缘分博客,在线音乐,在线视频,在线游戏,交友平台,33591.com欢迎您,Fate blog, online music, online video, online games, dating platform, 33591.com Welcome" name="description">
    <title>缘分博客,在线音乐,在线视频,在线游戏,交友平台,33591.com欢迎您,Fate blog, online music, online video, online games, dating platform, 33591.com Welcome</title>
    <link href="style/user.css" rel="stylesheet" type="text/css" />
    <script src="js/swfobject.js" type="text/javascript"></script>
    </head>
    <body>
    <div class="top">
    <ul>
    <div class="logo"></div>
    <div class="top1">
    <li>下载快接图标</li>
    <li style="cursor:hand;" onclick="window.external.addFavorite('http://www.33591.com','33591缘分网');">收藏本站</li>
    <li style="cursor:hand;" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.33591.com');return false;">设为首页</li>
    </div>
    <div class="top2"><form style="margin:0px;padding:0px;" action="userlogin.aspx?action=login" method=post id="form_1" name="form_1">
    <ul>
    <li class="login_input"><span class="name"> <input type="text" name="username" /></span><span class="pass"><input type="password" name="userpass" /></span><span class="btn"><img src="img/login_btn.gif" onclick='form_1.submit();' /></span></li>
    <li class="regs"><a href='reguser.aspx'>免费注册</a>   |   <a href='getpassword.aspx'>忘记密码</a> </li>
    </ul>
    </form></div>
    <div class="top3"></div>
    </ul>
    </div>
    <div class="nav">
    <ul>
    <li class='cur'><a href="default.aspx">首页</a></li>
    <li ><a href="mainmusic.aspx">音乐</a></li>
    <li ><a href="mainpic.aspx">相册</a></li>
    <li ><a href="mainnote.aspx">日志</a></li>
    <li ><a href="users.aspx">博客</a></li>
    <li ><a href="qinglv.aspx">情侣</a></li>
    <!--<li><a href="#">视频</a></li>
    <li><a href="#">影院</a></li>
    <li><a href="#">图库</a></li>
    <li><a href="#">游戏</a></li>-->
    </ul>
    </div><div class="main">
    <ul class="usti"></ul>
    <ul class="otturi45">
    <div class="elanjima"><script type="text/javascript">/*960*90,创建于2011-8-5*/ var cpro_id = 'u565422';</script>
    <script src="http://cpro.baidu.com/cpro/ui/c.js" type="text/javascript"></script></div>
    <div class="leftag">
      <div  class="tabb29">
        <div class="tabs">
          <li class="tabg">登录</li>
          </div>
        <div class="main123">
          <ul>
            <table width="226" height="111" border="0" align="center" cellpadding="0" cellspacing="0">
    <form style="margin:0px;" action="?action=login" method="post">
              <tr>
                <td colspan="3"></td>
              </tr>
              <tr>
                <td height="24" colspan="3">&nbsp;</td>
              </tr>
              <tr>
                <td width="16%" rowspan="6">&nbsp;</td>
                <td height="24" colspan="2">用户名</td>
              </tr>
              <tr>
                <td height="12" colspan="2"><input name="username" style="width:180px;" maxlength="18" /></td>
              </tr>
              <tr>
                <td height="24" colspan="2">密  码:</td>
              </tr>
              <tr>
                <td height="12" colspan="2"><input name="userpass" style="width:180px;" type="password" /></td>
              </tr>
              <tr>
                <td width="84%" height="24"><!--<span class="reg">找回密码</span>--> </td>
              </tr>
              <tr>
                <td><input name="submit" type="submit" value="  登录  " />
                    <input name="submit" type="button" onclick="location.href='reguser.aspx';" value="  注册  " /></td>
              </tr>
    </form>
            </table>
          </ul>
          </div>
      </div>
      <div class="sol71"><script type="text/javascript">/*250*250,创建于2011-8-5*/ var cpro_id = 'u565436';</script><script src="http://cpro.baidu.com/cpro/ui/c.js" type="text/javascript"></script></div>
        </div>
    <div class="rightag"><div  class="tabb224"><div class="main195"> </div>
    </div>
    </div>
    </ul>
    <ul class="asti"></ul>
    </div>
    <br />
    <div class="main">
    <ul class="usti"></ul>
    <ul class="link"><ul>
    <li><a href="gg" target="_blank">广告服务</a></li><li><a href="addlink.aspx" target="_blank">申请连接</a></li><li><a href="#">会员注册</a></li><li><a href="#">联系我们</a></li><li><a href="#">33591关于</a></li></ul>
    版权所有 (C) 新疆蓝天网络有限公司<br />
    ICP许可证:新ICP备10000886号  |   <script src="http://s15.cnzz.com/stat.php?id=2309959&web_id=2309959" language="JavaScript"></script>
    </ul>
      <ul class="asti"></ul>
    </div>
      <br />
    </body>
    </html>
    这是登录页面源代码
      

  2.   

    HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.CookieContainer = cc;
            request.AllowAutoRedirect = true;
            request.Referer = url;
            byte[] buff = Encoding.UTF8.GetBytes(postData);
            request.ContentLength = buff.Length;
            Stream stream = request.GetRequestStream();
            stream.Write(buff, 0, buff.Length);
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            return GetStringFromStream(response.GetResponseStream(), Encoding.UTF8);