Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.

Library written in Java to get clearance cookie (bypass) from Cloudflare IUAM a.k.a. DDoS Protection.

License

Notifications You must be signed in to change notification settings

giacomoferretti/cloudflare-scraper

Repository files navigation

Updates from the owner

21 March 2019:
Sorry, not working for now. CloudFlare changed it's protection method. Gonna work on a fix soon.

19 April 2019:
The challenge changed again... Also I didn't update the repo yet. I don't have much time to update it.

Cloudflare Scraper

Build Status Latest License Codacy Badge

This is a libray written in Java that helps you solve the IUAM challenge in websites protected by Cloudflare.

Example code

public static void main(String... args) throws URISyntaxException, IOException, ScraperException, InterruptedException, ScriptException {
    // Create CloudflareScraper object
    CloudflareScraper cloudflareScraper = new CloudflareScraperBuilder(new URI("URL"))
            .setConnectionTimeout(5000)
            .setReadTimeout(5000)
            .setChallengeDelay(4000) // At least 4000 milliseconds, otherwise Cloudflare won't give you a clearance cookie
            .build();

    // Check if site is protected by Cloudflare
    if (cloudflareScraper.connect()) {

        // Pass this cookies in your request
        List<HttpCookie> cookies = cloudflareScraper.getCookies();
    }
}

Add cookies using HttpURLConnection

HttpURLConnection connection = (HttpURLConnection) new URL("URL").openConnection();
for (HttpCookie cookie : cookies) {
    connection.setRequestProperty("Cookie", cookie.toString());
}

Add cookies using OkHttpClient

OkHttpClient okHttpClient = new OkHttpClient();
Request.Builder requestBuilder = new Request.Builder().url("URL");
for (HttpCookie cookie : cookies) {
    requestBuilder.addHeader("Cookie", cookie.toString());
}

Request request = requestBuilder.build();

Download

Maven

<dependency>
    <groupId>xyz.hexile</groupId>
    <artifactId>cloudflarescraper</artifactId>
    <version>1.0</version>
</dependency>
<repository>
    <id>jcenter</id>
    <name>jcenter-bintray</name>
    <url>http://jcenter.bintray.com</url>
</repository>

Gradle

dependencies {
    compile 'xyz.hexile:cloudflarescraper:1.0'
}

repositories {
    jcenter()
}

About

Library written in Java to get clearance cookie (bypass) from Cloudflare IUAM a.k.a. DDoS Protection.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages