c#webBrowser登录问题 [英] c# webBrowser log in problem
本文介绍了c#webBrowser登录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果使用此代码打开人脸书
if using this code to open face book
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("www.facebook.com");
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
并将其用于登录
and using this for log in
private void button2_Click(object sender, EventArgs e)
{
HtmlElement ele = webBrowser1.Document.GetElementById("email");
if (ele != null)
ele.InnerText = "eng_elgammal@yahoo.com";
ele = webBrowser1.Document.GetElementById("pass");
if (ele != null)
ele.InnerText = "***********";
HtmlElement logonForm = webBrowser1.Document.GetElementById("logon-submit"); if (logonForm != null)
logonForm.InvokeMember("click");
}
这放置了用户名和密码
但无法实现登录代码.
为什么?
this put the user name and password
but it doesn''t achieve log in code.
why??
推荐答案
从我的评论中发布为解决方案:
由于您尚未完成研究,因此无法正确理解html.input
没有内部文本,因为它是一个自闭标签-它具有value
属性.您正在做的是糟糕的设计(可能是)-正确查看Facebook API,不要使用像这样的黑登录方法...
希望这会有所帮助,
Ed
Posted as a solution from my comment:
Because you haven''t done your research and so don''t understand html properly. Aninput
doesn''t have inner text as it is a self closing tag - it has avalue
attribute. What you''re doing is poor design (probably) - look at the Facebook API properly and use that not some hacked login method like this...
Hope this helps,
Ed
这篇关于c#webBrowser登录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文