An intuitive web scraping toolkit with intelligent templates and interactive workflows
Project description
Quarry ๐ชจโ๏ธ
A modern Python toolkit for web data extraction with robust support for React, Vue, and other JavaScript frameworks.
๐ What is Quarry?
Quarry provides two powerful approaches for web scraping:
- โ๏ธ Quarry Tools - Interactive CLI pipeline for building extraction workflows
- โ๏ธ Miner Mode - Interactive pipeline assistant with Scout recommendations and templates
Key Feature: Resilient selectors that survive CSS framework updates (React CSS-in-JS, Vue scoped styles, etc.)
๐ Quick Start
Installation
pip install py-quarry
Requirements: Python 3.11+
New to Quarry? Try the Guided Tutorial
quarry foreman
The Foreman walks you through the complete 5-tool pipeline in ~2-3 minutes using Hacker News as a demo.
Your First Extraction
# Analyze a webpage
quarry scout https://example.com
# Extract data
quarry excavate schema.yml --url https://example.com
# Export results
quarry ship output.jsonl results.csv
๐ Full guide: USAGE_GUIDE.md | INSTALLATION.md
โ๏ธ Quarry Tools
5 integrated tools for complete extraction pipelines:
| Tool | Purpose | Example |
|---|---|---|
| ๐ก Scout | Analyze HTML & detect patterns | quarry scout <url> |
| ๐ Survey | Design extraction schemas | quarry survey create schema.yml |
| ๐จ Excavate | Execute data extraction | quarry excavate schema.yml --url <url> |
| โจ Polish | Transform & clean data | quarry polish data.jsonl --dedupe |
| ๐ฆ Ship | Export to CSV/JSON/SQLite/PostgreSQL | quarry ship data.jsonl output.csv |
Complete pipeline:
quarry scout <url> | quarry excavate | quarry polish --dedupe | quarry ship results.csv
๐ Detailed docs: docs/QUARRY_COMPLETE.md
โ๏ธ Miner Mode
Guided extraction pipeline with intelligent recommendations:
# Launch interactive miner
quarry miner
# Miner will:
# 1. Analyze page with Scout
# 2. Recommend selectors or offer templates
# 3. Extract data with pagination
# 4. Clean and deduplicate
# 5. Export to your format (CSV, PostgreSQL, etc.)
Choose your approach: Scout recommendations (fastest), templates (guided), or custom selectors (full control)
๐ Miner guide: USAGE_GUIDE.md
๐ฏ Modern Framework Support
The Problem: React/Vue sites use dynamic CSS classes (.css-17p10p8) that change with every build.
Quarry's Solution: Structural selectors that survive CSS changes:
# โ Brittle - breaks on rebuild
title: h3.css-17p10p8 a
# โ
Resilient - structural hierarchy
title: h3 a
Tools for Modern Sites
1. Selector Audit Tool
python scripts/audit_schema_selectors.py my_schema.yml
# Detects brittle selectors, suggests fixes
2. Selector Utilities
from quarry.lib.selectors import build_robust_selector
robust = build_robust_selector('h3.css-xyz a', ['tag'])
# Returns: 'h3 a'
3. Framework Detection
from quarry.framework_profiles import detect_framework
framework = detect_framework(html, soup, url)
# Automatically detects React, Vue, WordPress, etc.
๐ Complete guide: docs/MODERN_FRAMEWORKS.md
๐ Features
- โ Framework Detection - Automatic detection of 9+ frameworks
- โ Resilient Selectors - Survive CSS framework updates
- โ Rate Limiting - Token bucket with exponential backoff
- โ Robots.txt - Automatic parsing and compliance
- โ State Management - SQLite-based deduplication
- โ Multiple Exports - CSV, JSON, SQLite, Parquet, PostgreSQL
- โ Validation - Schema validation with Pydantic
- โ
Guided Tutorial -
quarry foremanfor interactive learning - โ Testing - 217 tests, 100% passing
๐ Project Structure
quarry/
โโโ lib/ # Core utilities
โ โโโ selectors.py # CSS selector utilities
โ โโโ http.py # HTTP client with rate limiting
โ โโโ robots.py # Robots.txt parser
โโโ tools/ # Quarry suite
โ โโโ scout/ # HTML analysis
โ โโโ survey/ # Schema designer
โ โโโ excavate/ # Extraction engine
โ โโโ polish/ # Data transformation
โ โโโ ship/ # Data export
โโโ framework_profiles/ # Framework detection
โโโ connectors/ # Data source connectors
โโโ transforms/ # Data transformations
โโโ sinks/ # Output writers
๐ Documentation
- Installation - Setup and requirements
- Usage Guide - Complete usage documentation
- Modern Frameworks - React/Vue/Next.js guide
- Selector Reference - Quick selector patterns
- Wizard Guide - YAML-based extraction
- Architecture - System design
- Testing - Running tests
- Troubleshooting - Common issues
โ๏ธ Configuration
The CLI and HTTP client can be tuned via environment variables:
Logging & HTTP:
QUARRY_LOG_LEVEL: Logging level (DEBUG,INFO,WARNING,ERROR). DefaultINFO.QUARRY_LOG_JSON: Set to1to emit JSON logs to stderr.QUARRY_OUTPUT_DIR: Base directory for schemas, extraction output, caches, and the Foreman tutorial. Defaults to the current working directory. When set, Quarry skips save-location prompts and writes all artifacts inside this directory.QUARRY_DEFAULT_RPS: Default requests-per-second per domain (float). Default1.0.QUARRY_HTTP_TIMEOUT: Default request timeout in seconds (int). Default30.QUARRY_HTTP_MAX_RETRIES: Default HTTP retries (int). Default3.PROXY_URL: HTTP/HTTPS proxy URL (also honors standardHTTP(S)_PROXY).QUARRY_MAX_CONTENT_MB: Max response size in MB (int). Rejects larger payloads.QUARRY_INTERACTIVE:1to prompt when robots.txt blocks (ethical default is non-interactive).QUARRY_IGNORE_ROBOTS:1to ignore robots.txt (testing only).
Database Exports:
QUARRY_POSTGRES_URL: PostgreSQL connection URL for database exports.
Examples:
export QUARRY_LOG_LEVEL=INFO
export QUARRY_DEFAULT_RPS=0.5
export QUARRY_HTTP_TIMEOUT=60
export QUARRY_HTTP_MAX_RETRIES=5
export QUARRY_MAX_CONTENT_MB=10
export PROXY_URL=http://proxy.internal:8080
export QUARRY_OUTPUT_DIR=/tmp/quarry_outputs
export QUARRY_POSTGRES_URL=postgresql://user:pass@localhost:5432/extractions
quarry excavate schemas/example.yml --url https://example.com -o out.jsonl
quarry ship out.jsonl postgresql://localhost/db # Export to PostgreSQL
๐งช Development
# Run tests
pytest # All tests
pytest tests/test_scout.py -v # Specific tool
# Code quality
ruff format . # Format code
ruff check . # Lint code
# Quick commands
make test # Run tests
make format # Format code
make check # Lint code
๐ค Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
To add a new framework profile:
# quarry/framework_profiles/frameworks/my_framework.py
class MyFrameworkProfile(FrameworkProfile):
name = "MyFramework"
def detect(self, html: str, soup: BeautifulSoup, url: str) -> int:
score = 0
if 'framework-marker' in html:
score += 50
return score
๐ License
MIT License - see LICENSE
๐ Acknowledgments
- Beautiful Soup - HTML parsing
- Pyarrow - Parquet support
- Click - CLI framework
- Rich - Terminal formatting
- Pydantic - Data validation
Happy Scraping! ๐
Project details
Release history Release notifications | RSS feed
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 py_quarry-2.0.9.tar.gz.
File metadata
- Download URL: py_quarry-2.0.9.tar.gz
- Upload date:
- Size: 189.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 |
589f90c3880e49bf1709bf0f862cd1b66f19f011d4d205b9a701baadd7193a19
|
|
| MD5 |
67b30648bf17c4c60fe577c45cd21e2d
|
|
| BLAKE2b-256 |
243f989ef3efaa6185e2b94e039969b04bbbe672b2f583ba540758736c82d59d
|
Provenance
The following attestation bundles were made for py_quarry-2.0.9.tar.gz:
Publisher:
pypi-publish.yml on russellbomer/quarry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_quarry-2.0.9.tar.gz -
Subject digest:
589f90c3880e49bf1709bf0f862cd1b66f19f011d4d205b9a701baadd7193a19 - Sigstore transparency entry: 747609980
- Sigstore integration time:
-
Permalink:
russellbomer/quarry@b1a45bf981f446ac10dbe3b584dab3ff66c1e431 -
Branch / Tag:
refs/tags/v2.0.9 - Owner: https://github.com/russellbomer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@b1a45bf981f446ac10dbe3b584dab3ff66c1e431 -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_quarry-2.0.9-py3-none-any.whl.
File metadata
- Download URL: py_quarry-2.0.9-py3-none-any.whl
- Upload date:
- Size: 158.0 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 |
1921705561b06dc54ec8192409bac6e0e4a90d8cfbe6673e88411deb58087f5c
|
|
| MD5 |
8d11524dff80514281ad17c0e1e2374c
|
|
| BLAKE2b-256 |
0a1a68bcd146f6103aeb5d1edf671042c5637ce42b8c812fb29057f899ab0c58
|
Provenance
The following attestation bundles were made for py_quarry-2.0.9-py3-none-any.whl:
Publisher:
pypi-publish.yml on russellbomer/quarry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_quarry-2.0.9-py3-none-any.whl -
Subject digest:
1921705561b06dc54ec8192409bac6e0e4a90d8cfbe6673e88411deb58087f5c - Sigstore transparency entry: 747609982
- Sigstore integration time:
-
Permalink:
russellbomer/quarry@b1a45bf981f446ac10dbe3b584dab3ff66c1e431 -
Branch / Tag:
refs/tags/v2.0.9 - Owner: https://github.com/russellbomer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@b1a45bf981f446ac10dbe3b584dab3ff66c1e431 -
Trigger Event:
push
-
Statement type: