webbrowser自动登录

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlElement name = webBrowser1.Document.GetElementById(“username”);
if (name != null)
name.SetAttribute(“value”, “superman”);
HtmlElement pass = webBrowser1.Document.GetElementById(“psw”);
if (pass != null)
pass.SetAttribute(“value”, “a1b2c3”);

HtmlElementCollection hecs=webBrowser1.Document.GetElementsByTagName(“input”);

foreach( HtmlElement hec in hecs)
{
if(hec.Name==”Submit”)
{

HtmlElement login = hec;
if (login != null)
login.InvokeMember(“click”);

}
}

}

未经允许不得转载:A66网 » webbrowser自动登录

赞 (0)
分享到:更多 ()

评论 0