Skip to main content

Universal AI-Powered Web Scraper Library

Project description

QwlCrapstar: Autonomous AI Data Extraction Agent

QwlCrapstar is a high-performance, agentic web scraping library designed for professional data extraction. It leverages Large Language Models (LLMs) to transform unstructured web content into validated, structured data without the need for brittle CSS selectors or XPaths.

The Core Concept (The "What")

Traditional web scraping relies on identifying specific HTML tags and classes. When a website's layout changes, the scraper breaks. QwlCrapstar operates on Semantic Intent. By providing a natural language "Mission" and a target data structure (Schema), the library uses AI to understand the context of the page, navigate its structure, and extract exactly what is requested, regardless of underlying code changes.

Why QwlCrapstar? (The "Why")

  1. Resilience: Scrapers do not break when a website shifts from a "table" layout to a "flexbox" layout.
  2. Reduced Development Time: No need to spend hours inspecting DOM structures. If a human can read the data, QwlCrapstar can extract it.
  3. Complex Logic Handling: Built-in support for semantic filtering and data normalization (e.g., converting "2 hours ago" into a standardized ISO date).
  4. Local & Cloud Flexibility: Support for elite cloud models (Perplexity, OpenAI) and private local models (Ollama).

Installation

pip install qwlcrapstar
playwright install chromium

Getting Started (The "How")

Level 1: Basic Mission

The most direct way to use the library is to provide a URL and a natural language instruction. QwlCrapstar will automatically infer the appropriate schema and execute the mission.

import asyncio
from qwl_crapstar import QwlCrapstar

async def main():
    # Automatically detects API keys in environment variables
    scraper = QwlCrapstar() 
    
    # Mission: Extract the latest 10 technology news items
    results = await scraper.scrape(
        url="https://news.ycombinator.com",
        prompt="Find 10 interesting technology stories"
    )
    print(results)

asyncio.run(main())

Professional Developer Guide

1. Advanced Schema Definition

For production applications, explicitly defining your data structure is recommended for consistency. QwlCrapstar supports class-based schemas using a specialized Field system.

from qwl_crapstar import QwlCrapstar, Schema, Field

class ProductSchema(Schema):
    name = Field("Exact product name", required=True)
    price = Field("Selling price", type=float, hint="Look for currency symbols")
    description = Field("Short item summary")
    specs = Field("Technical specifications", type=dict)

scraper = QwlCrapstar()
results = await scraper.scrape(
    url="https://example-shop.com/product/1",
    schema=ProductSchema
)

2. The Semantic Logic Engine

You can enforce strict extraction constraints using programmatic rules. This acts as a filter on the LLM's interpretation.

results = await scraper.scrape(
    url="https://linkedin.com/jobs",
    prompt="Senior Data Scientist roles",
    rules=[
        "Filter: Only include postings from the last 7 days",
        "Normalize: All salaries must be expressed as annual USD",
        "Constraint: Employer must be a Fintech company"
    ]
)

3. Complexity & Resource Management

The complexity_level parameter controls the depth of analysis and the resources allocated to the mission.

Level Use Case Rationale
basic Simple static pages Minimal latency, lower token consumption.
standard Most content websites Balanced rendering wait and context window.
advanced Dynamic JS-heavy sites Increased rendering wait and deeper context analysis.
elite Critical/Protected apps Maximum token window and rigorous structural analysis.

4. Enterprise Processing Pipeline

Post-extraction, you can route data through a series of processors for cleaning and deduplication.

from qwl_crapstar.core.processors import Pipeline, DataValidator, Deduplicator

# Build the pipeline
pipeline = Pipeline([
    DataValidator(schema=ProductSchema),
    Deduplicator(fields=["name", "price"])
])

# Process raw results
sanitized_data = await pipeline.run(raw_results)

Configuration & Credentials

QwlCrapstar features Auto-Discovery. It scans the following environment variables automatically: OPENAI_API_KEY, ANTHROPIC_API_KEY, GROQ_API_KEY, DEEPSEEK_API_KEY, PERPLEXITY_API_KEY.

LLM Provider Implementation Note
Perplexity Best for real-time web content and citation-accuracy.
OpenAI Industry standard for high-fidelity structured output.
Groq Exceptional speed for high-volume scraping tasks.
Ollama Entirely local; ensures zero data leaves your infrastructure.

Technical Architecture

The library operates through a three-stage pipeline:

  1. Browser Execution: A Playwright-based engine navigates to the target, handles rendering, and extracts a sanitized version of the DOM.
  2. Semantic Mapping: The LLM analyzes the content window based on the provided Mission, Schema, and Complexity level.
  3. Serialization: The LLM returns a validated JSON object that matches the requested schema constraints.

License

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qwlcrapstar-0.1.10.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qwlcrapstar-0.1.10-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file qwlcrapstar-0.1.10.tar.gz.

File metadata

  • Download URL: qwlcrapstar-0.1.10.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qwlcrapstar-0.1.10.tar.gz
Algorithm Hash digest
SHA256 785f6dd983656075d4c1505526119d3e6af0e5b93c91ef2c1db1b07ff0419c4c
MD5 8fe4cb10d3259e364f07ff7708a36a27
BLAKE2b-256 8d2a55e53f2187ddab60eb0829de577e100dc98b92f0bd9050b7927579344509

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwlcrapstar-0.1.10.tar.gz:

Publisher: publish.yml on Ranzim/QwlCrapStar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qwlcrapstar-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: qwlcrapstar-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qwlcrapstar-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 947a6217006bddfda5ebe85596c233520611e92607e034ae42a253b7bffe1f92
MD5 46a01f989f668af4532e755f77dde346
BLAKE2b-256 6c6ce025e1617d22eb3e7deb8ccbcf83d656c6c2713017fbfcbb83bf9869259a

See more details on using hashes here.

Provenance

The following attestation bundles were made for qwlcrapstar-0.1.10-py3-none-any.whl:

Publisher: publish.yml on Ranzim/QwlCrapStar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page