gpt4 book ai didi

c# - 指定的转换无效。 C# 网页浏览器

转载 作者:行者123 更新时间:2023-11-30 18:30:26 25 4
gpt4 key购买 nike

url="https://ipv4.google.com/sorry/IndexRedirect?continue=https://www.google.com/search%3Fq%3Dstackoverflow%2B%26rlz%3D1C1KMZB_enTR561TR561%26oq%3Dstac%26aqs%3Dchrome.1.69i59l3j69i60j69i57j69i60.5208j0j7%26sourceid%3Dchrome%26espv%3D210%26es_sm%3D122%26ie%3DUTF-8";

webBrowser1.Navigate(url);

if (url.Contains("ipv4.google.com"))
{
frm2.ShowDialog();
Application.DoEvents();
webBrowser1.Document.GetElementById("captcha").SetAttribute("value", frm2.code);
webBrowser1.Document.GetElementById("submit").InvokeMember("click");
}

异常(exception)是:

Specified cast is not valid.

webBrowser1.Document.GetElementById("captcha").SetAttribute("value", frm2.code);

最佳答案

在准备加载时使用文档。

string url = "https://ipv4.google.com/sorry/IndexRedirect?continue=https://www.google.com/search%3Fq%3Dstackoverflow%2B%26rlz%3D1C1KMZB_enTR561TR561%26oq%3Dstac%26aqs%3Dchrome.1.69i59l3j69i60j69i57j69i60.5208j0j7%26sourceid%3Dchrome%26espv%3D210%26es_sm%3D122%26ie%3DUTF-8";

WebBrowser webBrowser1 = new WebBrowser();
this.Controls.Add(webBrowser1);
webBrowser1.Dock = DockStyle.Fill;

webBrowser1.Navigate(url);

if (url.Contains("ipv4.google.com"))
{
webBrowser1.DocumentCompleted += handler;
}

private void handler(object sender, WebBrowserDocumentCompletedEventArgs e)
{
frm2.ShowDialog();
webBrowser1.Document.GetElementById("captcha").SetAttribute("value", frm2.code);
webBrowser1.Document.GetElementById("submit").InvokeMember("click");

webBrowser1.DocumentCompleted -= handler;
};

关于c# - 指定的转换无效。 C# 网页浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21451262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com