Metadata-Version: 2.4
Name: scraprime
Version: 0.1.1
Summary: Prime infrastructure for undetectable scraping. 3-tier WAF bypass & auto-healing parsers.
Home-page: https://github.com/Anees99/scraprime
Author: Anees Ur Rahman
Author-email: anisshewa@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: curl_cffi>=0.7.0
Requires-Dist: scrapling>=0.2.0
Requires-Dist: camoufox[geoip]>=0.4.0
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: selectolax>=0.3.21
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Scraprime Logo

<p align="center">
  <img src="./logo.png" alt="Scraprime Logo" width="200"/>
</p>

<h1 align="center">🛡 Scraprime</h1>
<p align="center">
  <strong>Prime infrastructure for undetectable scraping.</strong><br>
  A 3-tiered WAF bypass engine and auto-healing parser for Python.
</p>

<p align="center">
  <a href="https://pypi.org/project/scraprime/"><img src="https://img.shields.io/pypi/v/scraprime?color=blue&label=PyPI" alt="PyPI"></a>
  <a href="#"><img src="https://img.shields.io/badge/Python-3.8%2B-blue" alt="Python Version"></a>
  <a href="./LICENSE"><img src="https://img.shields.io/badge/License-MIT-green" alt="License"></a>
</p>

---

### 🚀 Features

Scraprime is built for developers who are tired of their scrapers breaking every time a website updates its UI or adds a WAF.

- **3-Tier WAF Bypass Engine:** Maximizes speed while guaranteeing data extraction.
  - **Tier 1 (Fast Lane):** curl_cffi with Chrome 120 TLS/JA3 impersonation (1-second response time).
  - **Tier 2 (Stealth):** scrapling stealth fetcher for basic JS challenges.
  - **Tier 3 (Heavy Artillery):** Camoufox headless browser with humanized mouse movements and geoip matching (beats DataDome & Cloudflare).
- **Auto-Healing Parser:** Uses `scrapling.Adaptor` to find data based on text proximity and regex. If a site changes its CSS tomorrow, your scraper won't break.
- **Automation Ready:** Built-in async webhook routing to instantly send scraped data to n8n, Make.com, or Zapier.

---

### 📦 Installation

Scraprime automatically installs all required dependencies (including Camoufox, GeoIP databases, and Scrapling) in one single command:

```bash
pip install scraprime
```
> No extra steps required. You're ready to scrape immediately.

---

### ⚡ Quick Start

```python
import asyncio
from scraprime import StealthFetcher, AdaptiveParser, send_to_n8n

async def main():
    url = "https://www.very.co.uk/some-product"
    
    # 1. Initialize Fetcher (Optionally add proxies)
    fetcher = StealthFetcher(
        proxy={"server": "http://ip:port", "username": "u", "password": "p"}
    )
    
    # 2. Fetch HTML (Automatically tries Tier 1, 2, and 3)
    html = await fetcher.fetch(url)
    
    # 3. Parse Data (Auto-healing)
    parser = AdaptiveParser(html)
    
    # Find the "Add to Basket" button, then look for a £ price near it
    price = parser.extract_nearby_regex("Add to Basket", r'[\£\$\€]\d+[.,]\d{2}')
    
    # 4. Send to n8n / Make.com
    if price:
        payload = {"url": url, "price": price}
        await send_to_n8n("https://your-n8n-webhook.com/webhook", payload)

asyncio.run(main())
```

---

### 🧠 How the Auto-Healing Parser Works

Most scrapers rely on brittle CSS classes like `div class="price-container-992"`. When the website updates its UI, the class changes to `price-container-993`, and the scraper breaks.

Scraprime uses **Structural Context**. It finds a stable anchor (like an "Add to Cart" button) and searches the surrounding HTML for a regex pattern (like a price). Even if the website completely changes its CSS tomorrow, Scraprime will still find the price because the button and the price are still next to each other.

---

### 🏗 Architecture

```
Target URL
   │
   ▼
[ Tier 1: curl_cffi ] ──(Success)──> Return HTML
   │
   (403 / WAF Detected)
   │
   ▼
[ Tier 2: scrapling ] ──(Success)──> Return HTML
   │
   (403 / WAF Detected)
   │
   ▼
[ Tier 3: Camoufox ]  ──(Success)──> Return HTML
   │
   ▼
Parse & Route to Webhook
```

---

### 📜 License

Distributed under the MIT License. See `LICENSE` for more information.

<p align="center">Built with ❤ by <a href="https://github.com/anees99">Anees Ur Rahman</a></p>
