Esempio n. 1
0
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="browser">浏览器</param>
        /// <param name="domains">被采集链接的Domain, Cookie</param>
        /// <param name="webDriverWaitTime">请求链接完成后需要等待的时间</param>
        /// <param name="option">选项</param>
        public WebDriverDownloader(Browser browser, string[] domains = null, int webDriverWaitTime = 200, Option option = null)
        {
            _webDriverWaitTime = webDriverWaitTime;
            _browser           = browser;
            _option            = option ?? new Option();
            if (domains != null)
            {
                foreach (var domain in domains)
                {
                    if (!string.IsNullOrWhiteSpace(domain) && !_domains.Contains(domain))
                    {
                        _domains.Add(domain);
                    }
                }
            }

            if (browser == Browser.Firefox && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Task.Factory.StartNew(() =>
                {
                    while (!_isDisposed)
                    {
                        IntPtr maindHwnd = WindowsFormUtil.FindWindow(null, "plugin-container.exe - 应用程序错误");
                        if (maindHwnd != IntPtr.Zero)
                        {
                            WindowsFormUtil.SendMessage(maindHwnd, WindowsFormUtil.WmClose, 0, 0);
                        }
                        Thread.Sleep(500);
                    }
                });
            }
        }
Esempio n. 2
0
        public FiddlerDownloader(string urlParten, Option option, int webDriverWaitTime = 200)
        {
            _option            = option;
            _option.Proxy      = "127.0.0.1:30000";
            _webDriverWaitTime = webDriverWaitTime;

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    IntPtr maindHwnd = WindowsFormUtil.FindWindow(null, "plugin-container.exe - 应用程序错误");
                    if (maindHwnd != IntPtr.Zero)
                    {
                        WindowsFormUtil.SendMessage(maindHwnd, WindowsFormUtil.WmClose, 0, 0);
                    }
                    Thread.Sleep(500);
                }
                // ReSharper disable once FunctionNeverReturns
            });

            _fiddlerClient = new FiddlerClient(30000, urlParten);
            _fiddlerClient.StartCapture();

            if (_downloader == null)
            {
                _downloader = this;
            }
        }
Esempio n. 3
0
        private void AutoCloseErrorDialog()
        {
#if NETFRAMEWORK
            var requireCloseErrorDialog = _browser == Browser.Firefox;
#else
            var requireCloseErrorDialog =
                _browser == Browser.Firefox && RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#endif
            if (requireCloseErrorDialog)
            {
                Task.Factory.StartNew(() =>
                {
                    while (!_isDisposed)
                    {
                        var intPtr = WindowsFormUtil.FindWindow(null, "plugin-container.exe - 应用程序错误");
                        if (intPtr != IntPtr.Zero)
                        {
                            WindowsFormUtil.SendMessage(intPtr, WindowsFormUtil.WmClose, 0, 0);
                        }

                        Thread.Sleep(500);
                    }
                });
            }
        }
        public WebDriverDownloader(Browser browser, int webDriverWaitTime = 200, Option option = null)
        {
            _webDriverWaitTime = webDriverWaitTime;
            _browser           = browser;
            _option            = option ?? new Option();

            if (browser == Browser.Firefox && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Task.Factory.StartNew(() =>
                {
                    while (!_isDisposed)
                    {
                        IntPtr maindHwnd = WindowsFormUtil.FindWindow(null, "plugin-container.exe - 应用程序错误");
                        if (maindHwnd != IntPtr.Zero)
                        {
                            WindowsFormUtil.SendMessage(maindHwnd, WindowsFormUtil.WmClose, 0, 0);
                        }
                        Thread.Sleep(500);
                    }
                });
            }
        }
        public WebDriverDownloader(Browser browser, int webDriverWaitTime = 200, Option option = null)
        {
            _webDriverWaitTime = webDriverWaitTime;
            _browser           = browser;
            _option            = option ?? new Option();

            if (browser == Browser.Firefox)
            {
                Task.Factory.StartNew(() =>
                {
                    while (true)
                    {
                        IntPtr maindHwnd = WindowsFormUtil.FindWindow(null, "plugin-container.exe - 应用程序错误");
                        if (maindHwnd != IntPtr.Zero)
                        {
                            WindowsFormUtil.SendMessage(maindHwnd, WindowsFormUtil.WmClose, 0, 0);
                        }
                        Thread.Sleep(500);
                    }
                    // ReSharper disable once FunctionNeverReturns
                });
            }
        }