Skip to main content

Official Python SDK for the Stealth Scraper API — snapshot, extract, and AI-assisted scraping with anti-bot bypass.

Project description

stealth-scraper (Python)

Official Python SDK for Stealth Scraper — the anti-bot-resistant web scraping API.

Status: beta — PyPI release coming with the Product Hunt launch (June 1, 2026). Until then, install from git (one-liner, works today).

Install

# During beta — install directly from GitHub:
pip install git+https://github.com/Rusheesonu/Stealth-Scraper.git#subdirectory=sdks/python

# After June 1 PyPI release:
pip install stealth-scraper

Quickstart

from stealth_scraper import StealthClient

client = StealthClient(api_key="ssk_...")        # or set STEALTH_SCRAPER_API_KEY

# Stealth snapshot — screenshot + structured element catalog
snap = client.snapshot("https://news.ycombinator.com/")
print(snap.title, snap.element_count)

# Run a saved template
result = client.extract(url="https://news.ycombinator.com/", template_id="t_xxx")
print(result.fields)

# AI-assisted one-shot extraction (no template needed)
data = client.assist_extract(
    url="https://news.ycombinator.com/",
    description="get the top 20 story titles, scores, and links",
)
print(data.template)   # the generated recipe
print(data.fields)     # extracted values

Async

import asyncio
from stealth_scraper import AsyncStealthClient

async def main():
    async with AsyncStealthClient(api_key="ssk_...") as client:
        snap = await client.snapshot("https://example.com")
        async for ev in client.snapshot_stream("https://heavy.example.com"):
            print(ev.event, ev.progress, ev.message)

asyncio.run(main())

Features

  • Typed result objectsSnapshotResult, ExtractResult, AssistExtractResult, Template.
  • Typed error envelopesAntiBotBlockError(vendor=...), PlanLimitError(used=, limit=), OverloadedError(retry_after_s=), RateLimitError, AuthError. Catch the kind of failure you actually want to handle, not a string.
  • Automatic idempotency keys — every mutating call sends an Idempotency-Key header (UUID4 if you don't pass one). Safe to retry.
  • Cost previewclient.estimate(url, schema=...) returns expected credits before you spend them.
  • Streaming snapshotsasync for ev in client.snapshot_stream(url): ....
  • Sync + async — same surface on both StealthClient and AsyncStealthClient.
  • Fully typedpy.typed marker shipped, mypy-clean.

Error handling

from stealth_scraper import StealthClient, AntiBotBlockError, RateLimitError, PlanLimitError

client = StealthClient(api_key="ssk_...")
try:
    client.snapshot("https://www.cloudflare-protected.example")
except AntiBotBlockError as e:
    print(f"blocked by {e.vendor}: {e.suggestion}")
except RateLimitError as e:
    print(f"slow down, retry in {e.retry_after_s}s")
except PlanLimitError as e:
    print(f"used {e.used}/{e.limit} — upgrade at {e.upgrade_url}")

Configuration

Argument Env var Default
api_key STEALTH_SCRAPER_API_KEY required
base_url https://api.stealthscraper.dev
timeout 120 seconds

Development

pip install -e ".[dev]"
pytest

RUN THIS TO PUBLISH

pip install build twine
python -m build           # produces dist/*.whl and dist/*.tar.gz
twine check dist/*
twine upload dist/*       # requires PyPI API token

License

MIT

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

stealth_scraper-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

stealth_scraper-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file stealth_scraper-0.1.0.tar.gz.

File metadata

  • Download URL: stealth_scraper-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for stealth_scraper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 775cc3caa0d805a7caa0673923421ad93b2a377e8ab9203810de339114e9db60
MD5 c91c710ed895a311e8af665f6401e5c0
BLAKE2b-256 f3216a0a1715be92f1fdc0c3f48c70836ebe603cafa57a1b3c4a866630a0ab09

See more details on using hashes here.

File details

Details for the file stealth_scraper-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stealth_scraper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7acb76445c42d64ef085e590f577b4d4efaf962add42480eac350e70257ee7ef
MD5 082dd243ff7812bfe72306d7b9405c97
BLAKE2b-256 b8d2bf165db374674b525e8cb75fe6e084e1887a65edc2a2218a4e0365efb567

See more details on using hashes here.

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