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() };
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); }
public static WebProxy CreateWebProxy(this ProxyConnectionCfg proxy) =>