Skip to content
Go HTTP RoundTripper that Solves the Cloudflare Challenge
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cfrt
.gitignore
LICENSE
README.md

README.md

cloudflare-roundtripper

Working Go implementation inspired by Anorov/cloudflare-scrape written in python

Example

import(
    "time"
    "net"
    "net/http"

    "github.com/caffix/cloudflare-roundtripper/cfrt"
)

func main() {
    var err error

    // Setup your client however you need it. This is simply an example
    client := &http.Client{
        Timeout: 15 * time.Second,
        Transport: &http.Transport{
            DialContext: (&net.Dialer{
                Timeout:   15 * time.Second,
                KeepAlive: 15 * time.Second,
                DualStack: true,
            }).DialContext,
        },
    }
    // Set the client Transport to the RoundTripper that solves the Cloudflare anti-bot
    client.Transport, err = cfrt.New(client.Transport)
    if err != nil {
        return
    }
    
    req, err := http.NewRequest("GET", "http://example.com/path", nil)
    if err != nil {
        return
    }
    
    resp, err := client.Do(req)
    if err != nil {
        return
    }
    // Use the response as you wish...
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.