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