首页 > 解决方案 > 如何使用 DotNetBrowser 捕获验证码图像对象

问题描述

我们在 DotNetBrowser 上显示的网站包含验证码图像元素。在代码元素中捕获此元素图像类型的方法是什么?

网址:https ://paydas.its.gov.tr/hesap_yonetimi/giris

browserView = new WinFormsBrowserView(BrowserFactory.Create(BrowserType.LIGHTWEIGHT));
//...
browserView.Browser.SetSize(1024, 768); 
Bitmap screenshot = browserView.Browser.ImageProvider.GetImage() as Bitmap; 
DOMElement captchaElement = browserView.Browser.GetDocument().GetElementById("imgCaptcha"); 
pictureBox1.Image = screenshot?.Clone(captchaElement.BoundingClientRect, screenshot.PixelFormat);

这种方法不健康。

标签: cdotnetbrowser

解决方案


我找到了解决方案。

在创建 Browser 对象后,我添加了以下代码片段。

int viewHeight = 20000;
            string[] switches = {
                    "--disable-gpu",
                    "--max-texture-size=" + viewHeight
            };
BrowserPreferences.SetChromiumSwitches(switches);

推荐阅读