简体   繁体   English

在C#中显示来自Webbrowser的验证码

[英]Show Captcha from webbrowser in c#

So I am trying to set up a tool that auto creates accounts but users need to complete captcha codes to verify they are human, I want to get what ever the captcha code image is and show it to the users, I know the elements ID but how would I get a component (or what component would I use) so it only shows that part of the webbroswer ? 因此,我正在尝试建立一个自动创建帐户的工具,但用户需要完成验证码代码以验证其是否为人类,我想获取验证码代码图像并将其显示给用户,我知道元素ID,但是我将如何获得组件(或使用什么组件),以便仅显示webbroswer的那一部分?

My code... 我的代码...

webBrowser1.Document.GetElementById("recaptcha_challenge_image")

But after that I am not sure what I would do ? 但是之后我不确定该怎么办? I tried something like... 我尝试过类似...

webBrowser1.Document.GetElementById("recaptcha_challenge_image") = pictureBox1.BackgroundImage;

I am not quite sure what to do the site I am trying to get the captcha code from is https://account.sonyentertainmentnetwork.com/liquid/reg/account/create-account!input.action 我不太确定我要从中获取验证码的网站是https://account.sonyentertainmentnetwork.com/liquid/reg/account/create-account!input.action

Put your code in the DocumentCompleted event to make sure the document has loaded: 将代码放入DocumentCompleted事件中,以确保已加载文档:

WebBrowser browser = new WebBrowser();
browser.DocumentCompleted += browser_DocumentCompleted;
browser.Navigate("https://account.sonyentertainmentnetwork.com/liquid/reg/account/create-account!input.action");

The DocumentCompleted event will fire several times, sometimes before the captcha has finished loading, so check for null before using it. DocumentCompleted事件将触发几次,有时会在验证码加载完成之前触发,因此请在使用前检查是否为null。 The code for the event looks as follows: 该事件的代码如下所示:

void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        WebBrowser browser = (WebBrowser)sender;
        var item = browser.Document.GetElementById("recaptcha_challenge_image");
        if (item != null)
            pictureBox1.Load(item.GetAttribute("src"));
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM