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")
- Resilience: Scrapers do not break when a website shifts from a "table" layout to a "flexbox" layout.
- Reduced Development Time: No need to spend hours inspecting DOM structures. If a human can read the data, QwlCrapstar can extract it.
- Complex Logic Handling: Built-in support for semantic filtering and data normalization (e.g., converting "2 hours ago" into a standardized ISO date).
- 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:
- Browser Execution: A Playwright-based engine navigates to the target, handles rendering, and extracts a sanitized version of the DOM.
- Semantic Mapping: The LLM analyzes the content window based on the provided Mission, Schema, and Complexity level.
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qwlcrapstar-0.1.11.tar.gz.
File metadata
- Download URL: qwlcrapstar-0.1.11.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52f2f550c70b0f74022c61928f70f225256890835177b9079bf8a0a3ecdf668f
|
|
| MD5 |
ea0a5c713f75b2e94aca8abd44f64d95
|
|
| BLAKE2b-256 |
15cca7fb853f917e79c37455b5f51d873d5bc0a5a1339ac831620296f796fa6a
|
Provenance
The following attestation bundles were made for qwlcrapstar-0.1.11.tar.gz:
Publisher:
publish.yml on Ranzim/QwlCrapStar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwlcrapstar-0.1.11.tar.gz -
Subject digest:
52f2f550c70b0f74022c61928f70f225256890835177b9079bf8a0a3ecdf668f - Sigstore transparency entry: 887205160
- Sigstore integration time:
-
Permalink:
Ranzim/QwlCrapStar@1f8bf878cb7a0e2279689288a43d9fb07527498c -
Branch / Tag:
refs/tags/v0.1.11 - Owner: https://github.com/Ranzim
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f8bf878cb7a0e2279689288a43d9fb07527498c -
Trigger Event:
release
-
Statement type:
File details
Details for the file qwlcrapstar-0.1.11-py3-none-any.whl.
File metadata
- Download URL: qwlcrapstar-0.1.11-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e845557a0b5e2d2470dd76ca34962f213fbbe201b9574f7c4f7adb66dc38e2a
|
|
| MD5 |
2cb8ec804b2e8e4997e1f83938ca0067
|
|
| BLAKE2b-256 |
52a01a42d9a0d0fef9eaddf0b4fde6a9695a582e2ab159af39497faa88278d11
|
Provenance
The following attestation bundles were made for qwlcrapstar-0.1.11-py3-none-any.whl:
Publisher:
publish.yml on Ranzim/QwlCrapStar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qwlcrapstar-0.1.11-py3-none-any.whl -
Subject digest:
7e845557a0b5e2d2470dd76ca34962f213fbbe201b9574f7c4f7adb66dc38e2a - Sigstore transparency entry: 887205249
- Sigstore integration time:
-
Permalink:
Ranzim/QwlCrapStar@1f8bf878cb7a0e2279689288a43d9fb07527498c -
Branch / Tag:
refs/tags/v0.1.11 - Owner: https://github.com/Ranzim
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f8bf878cb7a0e2279689288a43d9fb07527498c -
Trigger Event:
release
-
Statement type: