2

因此,我想创建一个难以用指纹检测到的屏幕外 CefSharp 刮刀。但是,当我使用它打开https://amiunique.org/fp并单击“查看更多详细信息”时,我的屏幕分辨率显示为“1366x768x0”,这意味着我的浏览器的 colorDepth 属性设置为零。

像这样

我的猜测是我需要在设置中启用某种图形选项,或者用类似的东西覆盖 window.screen 属性

window.screen = new function() { this.colorDepth = 24, this.pixelDepth = 24};

但这些似乎都不起作用。有没有办法解决这个问题,或者某种解决方法?

代码示例:

public static bool SiteReady;

static void Main(string[] args)
{
    Cef.Initialize();
    Task.Run(async () => await Scrape()).Wait();
    Helper.Log("Done!");
    Console.ReadLine();
}

public static async Task Scrape()
{
    using (var browser = new ChromiumWebBrowser("https://amiunique.org/fp"))
    {
        SiteReady = false;

        // create the loading handler
        EventHandler<LoadingStateChangedEventArgs> handler = null;
        handler = async (sender, args) =>
        {
            if (args.IsLoading) return;
            var view = (ChromiumWebBrowser)sender;
            view.LoadingStateChanged -= handler;

            // wait for the page to load completely
            await Task.Delay(20000);

            // change the window size to fit all displayed data
            view.Size = new Size(2000, 2500);

            // click the "view more details" button and wait for the next page to load
            await view.EvaluateScriptAsync("document.getElementById('detBut').click();");

            await Task.Delay(1000);

            while (view.IsLoading)
            {
                await Task.Delay(10);
            }

            // save the screenshot
            using (var task = await view.ScreenshotAsync())
            {
                task.Save("C:/Screens/screenshot.png");
            }

            // indicate that we are done with the page
            SiteReady = true;
        };

        browser.LoadingStateChanged += handler;

        while (SiteReady != true)
        {
            await Task.Delay(10);
        }
    }
}
4

0 回答 0