Skip to content

Utilities for working with Cloudflare-protected webpages

Notifications You must be signed in to change notification settings

gsemac/Gsemac.Net.Cloudflare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/"));

    }

}

About

Utilities for working with Cloudflare-protected webpages

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published