Awesome
CloudFlare Utilities
A .NET Standard Library to bypass Cloudflare's Anti-DDoS measure (JavaScript challenge) using a DelegatingHandler.
Contributors
Features
- No dependencies (e.g. no external JavaScript interpreter required)
- Easily integrated into your project (implemented as DelegatingHandler; e.g. can be used with HttpClient)
- Usable on many different platforms (NET Standard 1.1)
Usage
try
{
// Create the clearance handler.
var handler = new ClearanceHandler
{
MaxRetries = 2 // Optionally specify the number of retries, if clearance fails (default is 3).
};
// Create a HttpClient that uses the handler to bypass CloudFlare's JavaScript challange.
var client = new HttpClient(handler);
// Use the HttpClient as usual. Any JS challenge will be solved automatically for you.
var content = await client.GetStringAsync("http://protected-site.tld/");
}
catch (AggregateException ex) when (ex.InnerException is CloudFlareClearanceException)
{
// After all retries, clearance still failed.
}
catch (AggregateException ex) when (ex.InnerException is TaskCanceledException)
{
// Looks like we ran into a timeout. Too many clearance attempts?
// Maybe you should increase client.Timeout as each attempt will take about five seconds.
}