示例#1
0
 HttpClient CreateHttpClient(ProxyConnectionCfg proxy) =>
 new HttpClient(new HttpClientHandler
 {
     AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
     UseCookies             = false,
     Proxy = proxy.Url == null
   ? null
   : new WebProxy(proxy.Url, BypassOnLocal: true, new string[] { },
                  proxy.Creds != null ? new NetworkCredential(proxy.Creds.Name, proxy.Creds.Secret) : null),
     UseProxy = proxy.Url != null,
 })
 {
     Timeout = Proxy.TimeoutSeconds.Seconds()
 };
示例#2
0
        async Task <Browser> CreateBrowser(ILogger log, ProxyConnectionCfg proxy)
        {
            var browser = await Puppeteer.LaunchAsync(new() {
                Headless        = CollectCfg.Headless,
                DefaultViewport = new() { Width = 1024, Height = 1200 },
                ExecutablePath  = await ExecutablePath,
                Args            = new[] {
                    "--disable-dev-shm-usage", "--no-sandbox",
                    proxy != null ? $"--proxy-server={proxy.Url}" : null
                }.NotNull().ToArray()
            }); // logging has so much inconsequential errors we ignore it

            return(browser);
        }
示例#3
0
 public static WebProxy CreateWebProxy(this ProxyConnectionCfg proxy) =>