CF-Clearance-Scraper

Xewdy444MIT活跃维护

自动获取被 Cloudflare 挑战拦截的网站所下发的 cf_clearance Cookie,方便爬虫绕过验证继续访问。

A simple program for scraping Cloudflare clearance (cf_clearance) cookies from websites issuing Cloudflare challenges to visitors

暂无版本512star58fork同步于 2026-11-10 17:59 UTC

怎么上手

由 README 提炼,执行前请确认
pip install -r requirements.txt
python main.py -f cookies.json https://example.com
硬件要求按 README 说明

README 未说明显存或 GPU 要求,但需下载并安装 Google Chrome 作为浏览器后端

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用无头浏览器自动过 Cloudflare 挑战,抓取 cf_clearance cookie 供后续请求复用

自动获取被 Cloudflare 挑战拦截的网站所下发的 cf_clearance Cookie,方便爬虫绕过验证继续访问。

核心能力

  • 支持 JavaScript、managed、interactive 三类 Cloudflare 挑战
  • 用无头 Chrome 打开目标页并自动求解挑战
  • 输出 cf_clearance 及对应 User-Agent,可写入 JSON 文件
  • 可生成带 cookie 和 UA 的 cURL、Wget、aria2 命令
  • 支持代理、自定义 UA、超时及禁用 HTTP/2、HTTP/3

容易踩的坑

必须先在本机安装 Google Chrome,仅装 Python 依赖无法运行;复用 cookie 时请求的 User-Agent 和 IP 必须与抓取时一致,否则仍会被拦;UA 选择会影响能否通过挑战,必要时用 -ua 指定

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    CF-Clearance-Scraper

    A simple program for scraping Cloudflare clearance (cf_clearance) cookies from websites issuing Cloudflare challenges to visitors. This program works on all Cloudflare challenge types (JavaScript, managed, and interactive).

    Clearance Cookie Usage

    In order to bypass Cloudflare challenges with the clearance cookies, you must make sure of two things:

    • The user agent used to fetch the clearance cookie must match the user agent being used within the requests that use the clearance cookie
    • The IP address used to fetch the clearance cookie must match the IP address being used to make the requests that use the clearance cookie
    flowchart
    	N14e["cf_clearance"]
    	N14f["IP Address"]
    	N150["User Agent"]
    	N14e --> N14f
    	N14e --> N150
    

    Installation

    Download and install Google Chrome.

    Then, install the Python dependencies:

    $ pip install -r requirements.txt
    

    Usage

    [!WARNING] Depending on the user agent used, it may affect your ability to solve the Cloudflare challenge.

    usage: main.py [-h] [-f FILE] [-t TIMEOUT] [-p PROXY] [-ua USER_AGENT] [--disable-http2] [--disable-http3] [--headed] [-ac] [-c] [-w] [-a] URL
    
    A simple program for scraping Cloudflare clearance (cf_clearance) cookies from websites issuing Cloudflare challenges to visitors
    
    positional arguments:
      URL                   The URL to scrape the Cloudflare clearance cookie from
    
    options:
      -h, --help            show this help message and exit
      -f FILE, --file FILE  The file to write the Cloudflare clearance cookie information to, in JSON format
      -t TIMEOUT, --timeout TIMEOUT
                            The timeout in seconds to use for solving challenges
      -p PROXY, --proxy PROXY
                            The proxy server URL to use for the browser requests
      -ua USER_AGENT, --user-agent USER_AGENT
                            The user agent to use for the browser requests
      --disable-http2       Disable the usage of HTTP/2 for the browser requests
      --disable-http3       Disable the usage of HTTP/3 for the browser requests
      --headed              Run the browser in headed mode
      -ac, --all-cookies    Retrieve all cookies from the page, not just the Cloudflare clearance cookie
      -c, --curl            Get the cURL command for the request with the cookies and user agent
      -w, --wget            Get the Wget command for the request with the cookies and user agent
      -a, --aria2           Get the aria2 command for the request with the cookies and user agent
    

    Example

    $ python main.py -f cookies.json https://sergiodemo.com/security/challenge/legacy-challenge
    [14:24:27] [INFO] Launching headless browser...
    [14:24:27] [INFO] Going to https://sergiodemo.com/security/challenge/legacy-challenge...
    [14:24:28] [INFO] Solving Cloudflare challenge [Interactive]...
    [14:24:31] [INFO] Cookie: cf_clearance=SkyEdEGvKp1BBA2NpRW3Azsw5neMD6sEEqJd6jOCCfs-1736886257-1.2.1.1-cam47ywp3q_yKE1bw0lZ2YS83dnh_BsIHtS7earbsYE.AxQDBtZiifiHvp1nZGRhABaSdjU7XRQpUCVwUSrlJGH8DXr50YR18pNLxBvcEJFO2gPMxr.ZjKze8rWgM9H4rPeET67jzAo_ZRpNP6hGCvdyO62VVCtqDBQDKhKZz9yZQp7YEHK7tchQIteVgu.dUxYdan5_D.R0zewnS382BP0w1AoTf2p40.lQwbhgildEiKG14xACd13V4EEthkZV0dnliwcn35rT3h32ODf50MABQNSQ8WjhZhbLSNOPO_zEhrK9R0Yn4eBuRKvnL9_x9jKvaBPDPAgyiZv_VzFP_g
    [14:24:31] [INFO] User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
    [14:24:31] [INFO] Writing Cloudflare clearance cookie information to cookies.json...