Skip to main content

Crawl4AI Loader for PureCPP

This module provides a Crawl4AILoader, a data loader designed to integrate the crawl4ai web crawling library with the purecpp_extract data loading framework. It allows you to easily fetch web page content as Markdown and load it into RAGDocument objects, ready for use in Retrieval-Augmented Generation (RAG) pipelines.

✨ Features

  • Simple Web Content Extraction: Leverages crawl4ai to fetch the content of a single URL.
  • Markdown Conversion: Automatically converts the fetched HTML content into clean Markdown.
  • RAG-Ready Output: Wraps the extracted content and metadata into RAGDocument objects, the standard format for the PureCPP ecosystem.
  • Asynchronous by Design: Built with asyncio for efficient, non-blocking I/O operations.
  • Configurable: Accepts a BrowserConfig object to customize the crawling behavior (e.g., setting user agents, handling cookies).

⚙️ Installation

Before using the loader, ensure you have Python 3.10+ and the necessary libraries installed.

  1. Clone the repository (if applicable) or ensure your project is set up.
  2. Create and activate a virtual environment:
    uv venv 
    source .venv/bin/activate
    uv sync
    

🚀 Usage

The loader is straightforward to use. Instantiate Crawl4AILoader with a target URL and a BrowserConfig, then call its load method.

For a complete, runnable script, please refer to the loader.py file in the project directory.

Basic Usage Pattern:

import asyncio
from purecpp_crawl4ai.loader import Crawl4AILoader, BrowserConfig

async def run_loader():
    # 1. Configure the browser
    config = BrowserConfig()

    # 2. Instantiate the loader with a target URL
    loader = Crawl4AILoader("[https://www.example.com](https://www.example.com)", config)

    # 3. Load the content asynchronously
    documents = await loader.load()

    # 4. Use the resulting documents
    for doc in documents:
        print(f"Loaded content from: {doc.metadata['url']}")
        print(f"Snippet: {doc.page_content[:100]}...")

if __name__ == "__main__":
    asyncio.run(run_loader())

Testing

The project includes a test suite to ensure the loader functions correctly. The tests use unittest.mock to simulate the behavior of AsyncWebCrawler, allowing for fast and reliable testing without making actual network requests.

Ensure unittest is available (it's part of the Python standard library).

Navigate to the project's root directory in your terminal.

Run the tests using the following command:

python -m unittest test_loader.py

Metadata

Release files for purecpp-crawl4ai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for purecpp-crawl4ai 0.1.0
File Size Uploaded Provenance Actions
purecpp_crawl4ai-0.1.0.tar.gz 4.6 kB Without provenance Details for purecpp_crawl4ai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for purecpp-crawl4ai 0.1.0
File Interpreter ABI Platform Actions
purecpp_crawl4ai-0.1.0-py3-none-any.whl Python 3 none any Details for purecpp_crawl4ai-0.1.0-py3-none-any.whl

Total release size: 8.8 kB

Release files / purecpp_crawl4ai-0.1.0.tar.gz

Download URL purecpp_crawl4ai-0.1.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
af2eff1166e9591c458dd7fc8902660d23ff32de3bb88ac8384ee42099da8eaf
BLAKE2b-256 checksum
How to use checksums
dc18aa555ad673b22559b2a39b3b2e37546f77f9a989e06ac52726ef6b51c2e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / purecpp_crawl4ai-0.1.0-py3-none-any.whl

Download URL purecpp_crawl4ai-0.1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
989d8aa48cd88d8ee3a6690dc950aec5cd4b15af5e8806b9b41ae8a30b995057
BLAKE2b-256 checksum
How to use checksums
690d13bc47581257ff68fb475de65b55dda45a7232896d86600fd6793afd4832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Security for purecpp-crawl4ai 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page