163邮箱自动登录

在winform窗体上,放一个WebBrowser控件,就行了。

Code

                if (str.Length < 1)
                    {
                        str = em.Id;
                    }

                
if ((str == "username"|| (str == "password"|| (str == "登录邮箱"))
                {
                    
switch (str)
                    {
                        
case "username": em.SetAttribute("value""liukuo.lk"); break;
                        
case "password": em.SetAttribute("value""123456"); break;
                        
case "登录邮箱": btn = em; break;
                        
defaultbreak;
                    }
                }
            }
            btn.InvokeMember(
"click");
            doc.Forms[
"login163"].InvokeMember("登录邮箱");
        }

        
private void Form1_Load(object sender, EventArgs e)
        {
            webBrowser1.Navigate(
"http://mail.163.com/");
        }
    }
}

用户名和密码要写成你自己的邮箱用户名和密码,这样才能登陆邮箱。

完成程序下载

webBrowser1执行js:
  HtmlDocument doc = webBrowser1.Document;


  doc.InvokeScript("submitForm", new object[] { });

webBrowser1增加post数据:

 HtmlElement add = doc.CreateElement("<input name='bssCredentials.operatorId' value='" + value + "' />");
 doc.Forms["loginForm"].AppendChild(add);

查看Post数据

引用system32下SHDocVw.dll

Form_Load()里面:

 SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)webBrowser1.ActiveXInstance;
            wb.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(WebBrowser_BeforeNavigate2);

       private void WebBrowser_BeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
        {
            string postDataText = System.Text.Encoding.ASCII.GetString(PostData as byte[]);
        }

posted on 2009-03-11 12:52  几度夕阳红了  阅读(1136)  评论(0编辑  收藏  举报