日期:2014-05-17  浏览次数:21029 次

如何模拟登陆?当登陆按钮是图片?保存session。
http://www.xxx.com/login/login_index.jsp
要模拟登陆的网址。

<form name="formreg" id="formreg" method="post" target="UserCenter" style="float:left;margin:0;padding:0;" onSubmit="return loginchk();">

    <div class="nrikey">

      <ul>

        <li>用户名</li>

        <li class="nname01">

          <input name="us" id="us" type="text" class="nname" />

        </li>

      </ul>

      <ul>

        <li>密 码</li>

        <li class="nname01">

          <input name="_pwd" id="_pwd" type="password" class="nname" />

        </li>

      </ul>

    </div>

    <div class="namebot"><img src="/images/index2011new03qt_19.jpg" style="cursor: pointer;" width="50" height="44" onClick="if(document.formreg.onsubmit()!=false){document.formreg.submit();setTimeout('window.location.reload()',3000);}"/></div>
    </form>

-----------------------------------------------------
-----------------------------------------------------
上面是要模拟的网站代码


 class PostGetWebRequest
    {
        private string userName;
        private string password;
        private string submit;
        private string loginUrl;
        private string locationUrl;
        private CookieContainer myCookieContainer;
        private HttpWebRequest request;
        private HttpWebResponse response;
        private Stream stream;
        private StreamReader streamReader;
        private string src = "";
        private string postData;
        private string htmlUserName;
        private string htmlPassword;
        private string htmlSubmit;

        #region 类的成员 类的成员
        public string UserName
        {
            get { return userName; }
            set { userName =&nbs