# venomous/cloudscraper architecture

> Architecture diagram of the GitHub repository venomous/cloudscraper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/venomous/cloudscraper
- Repository: https://github.com/venomous/cloudscraper

## Overview

##### Main Components

a. Core Components:
- Cloudscraper Client
- JavaScript Interpreter System
- Captcha Solver Integration
- User Agent Manager
- Request Handler

b. External Components:
- Target Website with Cloudflare Protection
- Third-party Captcha Services
- JavaScript Engines/Interpreters

##### Client Layer
- Connection to the Request Handler

##### Processing Layer
- Native Interpreter
- Node.js
- ChakraCore
- V8
- js2py
- Captcha Processing System with supported services:
- 2captcha
- anticaptcha
- CapSolver
- CapMonster
- DeathByCaptcha
- 9kw

##### Integration Layer
- Connection to external JavaScript engines
- Integration with captcha solving services
- Connection to target websites

##### Flow Representation

**Client Request → Request Handler → Cloudflare Detection →**
**JavaScript Challenge Processing → Captcha Processing (if needed) →**
**Token Generation → Final Request to Target Site**

##### Component Details

**Cloudscraper Client:**
- Session Management
- Cookie Handling
- Token Management

**JavaScript Interpreter System:**
- Multiple Engine Support
- Challenge Solving
- Script Execution

**Captcha Solver:**
- Provider Selection
- API Integration
- Response Processing

**User Agent Manager:**
- Browser Simulation
- Platform Detection
- Custom User Agent Support

##### Technical Notes

- Required Python version (3.x)
- Dependencies (Requests, requests_toolbelt)
- Supported JavaScript engines
- Captcha service integration points

##### Implementation Details

- Cookie management system
- Token generation process
- Request/Response handling
- Challenge solving mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CS[Cloudscraper Client]:::core
        click CS "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/__init__.py"
        CF[Cloudflare Handler]:::core
        click CF "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/cloudflare.py"
        UA[User Agent Manager]:::core
        click UA "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/user_agent/__init__.py"
        EH[Error Handler]:::core
        click EH "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/exceptions.py"
        HP[Helper Utilities]:::core
        click HP "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/help.py"
    end

    subgraph "JavaScript Interpreters"
        NI[Native Interpreter]:::interpreter
        click NI "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/interpreters/native.py"
        NJ[Node.js]:::interpreter
        click NJ "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/interpreters/nodejs.py"
        CC[ChakraCore]:::interpreter
        click CC "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/interpreters/chakracore.py"
        V8[V8 Engine]:::interpreter
        click V8 "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/interpreters/v8.py"
        JS[js2py]:::interpreter
        click JS "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/interpreters/js2py.py"
        JU[JSUnfuck]:::interpreter
        click JU "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/interpreters/jsunfuck.py"
    end

    subgraph "Captcha Services"
        TC[2captcha]:::captcha
        click TC "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/captcha/2captcha.py"
        AC[Anticaptcha]:::captcha
        click AC "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/captcha/anticaptcha.py"
        CS2[CapSolver]:::captcha
        click CS2 "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/captcha/capsolver.py"
        CM[CapMonster]:::captcha
        click CM "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/captcha/capmonster.py"
        DB[DeathByCaptcha]:::captcha
        click DB "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/captcha/deathbycaptcha.py"
        KW[9kw]:::captcha
        click KW "https://github.com/VeNoMouS/cloudscraper/blob/master/cloudscraper/captcha/9kw.py"
    end

    subgraph "External Systems"
        CFP[Cloudflare Protected Site]:::external
        JSE[External JS Engines]:::external
        CAS[Captcha API Services]:::external
    end

    CS --> CF
    CF --> UA
    CF --> EH
    CF --> HP

    CF --> NI & NJ & CC & V8 & JS & JU
    NI & NJ & CC & V8 & JS & JU --> JSE

    CF --> TC & AC & CS2 & CM & DB & KW
    TC & AC & CS2 & CM & DB & KW --> CAS

    CF --> CFP

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef interpreter fill:#e67e22,stroke:#d35400,color:white
    classDef captcha fill:#27ae60,stroke:#219a52,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Interpreters]:::interpreter
        L3[Captcha Services]:::captcha
        L4[External Systems]:::external
    end
```
