Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1.67 KB

README.md

File metadata and controls

37 lines (24 loc) · 1.67 KB

Gsemac.Net.Cloudflare

NuGet NuGet

Gsemac.Net.Cloudflare is a library for interacting with Cloudflare-protected websites designed to be compatible with .NET Framework 4.0 and later.

Classes are provided for passing HttpWebRequest-based requests through cloudscraper, FlareSolverr, and Selenium.

Usage

The bypass is implemented by use of the delegating handler implementation from Gsemac.Net. To use FlareSolverr, first register the FlareSolverrService and FlareSolverrChallengeHandler services. WebClientFactory will use the handler to pass requests through FlareSolverr.

static ServiceProvider CreateServiceProvider() {

    return new ServiceCollection()
        .AddSingleton<ILogger, ConsoleLogger>()
        .AddSingleton<IWebClientFactory, WebClientFactory>()
        .AddSingleton<IFlareSolverrService, FlareSolverrService>()
        .AddSingleton<WebRequestHandler, FlareSolverrChallengeHandler>()
        .BuildServiceProvider();

}

static void Main(string[] args) {

    using (ServiceProvider serviceProvider = CreateServiceProvider()) {

        IWebClientFactory webClientFactory = serviceProvider.GetRequiredService<IWebClientFactory>();

        using (IWebClient webClient = webClientFactory.Create()) 
            Console.WriteLine(webClient.DownloadString("https://example.com/"));

    }

}