我想知道是否可以让用户通过单击按钮通过第三方网站登录特定的谷歌帐户,假设凭据是由网站本身提供的?如果是的话,谁能告诉我这是如何实现的?
问问题
142 次
1 回答
0
为此,您必须查看第 3 方站点的页面源并找到用户名、密码文本框和提交按钮的 ID。(如果您提供链接,我会为您检查)。然后使用此代码:
//add a reference to Microsoft.mshtml in solution explorer
using mshtml;
private SHDocVw.WebBrowser_V1 Web_V1;
Form1_Load()
{
Web_V1 = (SHDocVw.WebBrowser_V1)webBrowser1.ActiveXInstance;
}
webBrowser1_Document_Complete()
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
if (webBrowser1.Url.ToString() == "YourLoginSite.Com")
{
try
{
HTMLDocument pass = new HTMLDocument();
pass = (HTMLDocument)Web_V1.Document;
HTMLInputElement passBox = (HTMLInputElement)pass.all.item("PassIDThatyoufoundinsource", 0);
passBox.value = "YourPassword";
HTMLDocument log = new HTMLDocument();
log = (HTMLDocument)Web_V1.Document;
HTMLInputElement logBox = (HTMLInputElement)log.all.item("loginidfrompagesource", 0);
logBox.value = "yourlogin";
HTMLInputElement submit = (HTMLInputElement)pass.all.item("SubmitButtonIDFromPageSource", 0);
submit.click();
}
catch { }
}
}
}
您能否更具体一点并提供更多详细信息,例如哪个站点?谁的证件?
于 2013-07-09T01:21:08.680 回答