Skip to main content

wscrape

Fast async web scraper — CLI tool, Python library, and AI agent skill.

wscrape is a production-ready Python package that scrapes websites, optionally crawls links recursively, and returns structured data suitable for AI consumption.

Installation

pip install wscrape

For development:

pip install wscrape[dev]

CLI Usage

# Scrape a single page
wscrape https://example.com

# Deep crawl with depth limit
wscrape https://example.com --deep --max-depth 2

# Save results to a file
wscrape https://example.com --deep --save --output data.json

# CSV output
wscrape https://example.com --format csv --save --output data.csv

# Custom rate limiting (milliseconds between requests)
wscrape https://example.com --deep --rate 500

CLI Options

Option Description Default
<url> Target URL to scrape (required)
--deep Recursively crawl same-domain links False
--save Save output to a file False
--output <file> Output file path output.json
--format <json|csv> Output format json
--max-depth <n> Maximum recursion depth 1
--rate <ms> Delay between requests in ms 200
--verbose / -v Enable debug logging False

Python Library Usage

from wscrape import run_scraper

# Synchronous — works everywhere
results = run_scraper("https://example.com", deep=True, max_depth=2)
for page in results:
    print(page["url"], page["title"])

Async Usage

import asyncio
from wscrape import async_run_scraper

results = asyncio.run(
    async_run_scraper("https://example.com", deep=True, max_depth=2)
)

AI Agent Skill

wscrape is designed to be called programmatically by AI agents (Claude, OpenAI, etc.):

from wscrape import run_scraper

# Returns list[dict] with keys: url, title, text, links, depth
data = run_scraper("https://example.com")

Output Format

Each scraped page produces:

{
  "url": "https://example.com",
  "title": "Example Domain",
  "text": "Example Domain This domain is for use in illustrative examples ...",
  "links": ["https://www.iana.org/domains/example"],
  "depth": 0
}

Architecture

wscrape/
  __init__.py      # Public API & AI skill interface (run_scraper, async_run_scraper)
  __main__.py      # python -m wscrape support
  cli.py           # CLI entry point (argparse)
  config.py        # ScrapeConfig dataclass
  exceptions.py    # Custom exception hierarchy
  core/
    fetcher.py     # Async HTTP client with retries & backoff
    parser.py      # HTML parsing (lxml) — title, text, links, CSS, XPath
    crawler.py     # BFS crawler with rate limiting & same-domain policy
    output.py      # JSON / CSV serialisation & file output
tests/
  test_fetcher.py  # Fetcher unit tests (mocked HTTP)
  test_parser.py   # Parser unit tests
  test_crawler.py  # Crawler unit tests (mocked HTTP)
  test_cli.py      # CLI integration tests

Development

git clone https://github.com/wscrape/wscrape.git
cd wscrape
pip install -e ".[dev]"
pytest

License

MIT

Metadata

Release files for scrape-cli-itsthelastcookie 1.0.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 scrape-cli-itsthelastcookie 1.0.0
File Size Uploaded
scrape_cli_itsthelastcookie-1.0.0.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scrape-cli-itsthelastcookie 1.0.0
File Interpreter ABI Platform
scrape_cli_itsthelastcookie-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.4 kB

Release files / scrape_cli_itsthelastcookie-1.0.0.tar.gz

Download URL scrape_cli_itsthelastcookie-1.0.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
67e96d9e0e72c585266388594b66769abe9b24c1f94ed2b5dfc88ca7457b9e4c
BLAKE2b-256 checksum
How to use checksums
f1454a7f741f322f5f2a461c3a5df7a811da2af4cc2993894138b16341b23f5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / scrape_cli_itsthelastcookie-1.0.0-py3-none-any.whl

Download URL scrape_cli_itsthelastcookie-1.0.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2862fddf40595b39386de2cde00236f5ce4871b4c6b3a9f818f8b4e0390c8e53
BLAKE2b-256 checksum
How to use checksums
8af7f6f7b48931f3359ac318f8ea254b31ceb701189111ffc4241727e862242d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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