Metadata-Version: 2.5
Name: silkworm-rs
Version: 0.14.0
Summary: Async-first web scraping framework built on wreq and scraper-rs
Project-URL: Homepage, https://github.com/BitingSnakes/silkworm
Project-URL: Repository, https://github.com/BitingSnakes/silkworm
Project-URL: Documentation, https://bitingsnakes.github.io/silkworm/
Project-URL: Issues, https://github.com/BitingSnakes/silkworm/issues
Author-email: Yehor Smoliakov <egorsmkv@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Yehor Smoliakov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: asyncio,crawler,html,http,spider,web-scraping
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Framework :: Trio
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Internet
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
Classifier: Topic :: Text Processing :: Markup :: Markdown
Classifier: Topic :: Text Processing :: Markup :: XML
Classifier: Typing :: Typed
Requires-Python: <3.16,>=3.13
Requires-Dist: charset-normalizer==3.5.1
Requires-Dist: fast-h2m==0.4.4
Requires-Dist: rxml==3.0.0
Requires-Dist: scraper-rust>=0.11.0
Requires-Dist: wreq>=0.12.2
Provides-Extra: avro
Requires-Dist: fastavro==1.12.2; extra == 'avro'
Provides-Extra: cassandra
Requires-Dist: cassandra-driver==3.30.1; (sys_platform != 'win32' and python_version < '3.14') and extra == 'cassandra'
Provides-Extra: cdp
Requires-Dist: websockets==17.1; extra == 'cdp'
Provides-Extra: couchdb
Requires-Dist: aiocouch==4.0.1; extra == 'couchdb'
Provides-Extra: duckdb
Requires-Dist: duckdb==1.5.5; extra == 'duckdb'
Provides-Extra: dynamodb
Requires-Dist: aioboto3==15.5.0; extra == 'dynamodb'
Provides-Extra: elasticsearch
Requires-Dist: elasticsearch[async]==9.5.1; extra == 'elasticsearch'
Provides-Extra: excel
Requires-Dist: openpyxl==3.1.5; extra == 'excel'
Provides-Extra: ftp
Requires-Dist: aioftp==0.28.3; extra == 'ftp'
Provides-Extra: gsheets
Requires-Dist: google-api-python-client==2.200.0; extra == 'gsheets'
Requires-Dist: google-auth==2.58.1; extra == 'gsheets'
Provides-Extra: iggy
Requires-Dist: apache-iggy==0.9.0; (python_version < '3.14') and extra == 'iggy'
Provides-Extra: memray
Requires-Dist: memray==1.20.0; extra == 'memray'
Provides-Extra: mongodb
Requires-Dist: motor==3.7.1; extra == 'mongodb'
Provides-Extra: msgpack
Requires-Dist: ormsgpack==1.12.2; (python_version < '3.15') and extra == 'msgpack'
Provides-Extra: mysql
Requires-Dist: aiomysql==0.3.2; extra == 'mysql'
Provides-Extra: onionlink
Requires-Dist: onionlink==0.1.2; (python_version < '3.15') and extra == 'onionlink'
Provides-Extra: polars
Requires-Dist: polars==1.44.2; extra == 'polars'
Provides-Extra: postgresql
Requires-Dist: asyncpg==0.31.0; extra == 'postgresql'
Provides-Extra: rsloop
Requires-Dist: rsloop>=0.1.53; extra == 'rsloop'
Provides-Extra: s3
Requires-Dist: opendal==0.47.10; extra == 's3'
Provides-Extra: sftp
Requires-Dist: asyncssh==2.24.0; extra == 'sftp'
Provides-Extra: snowflake
Requires-Dist: snowflake-connector-python==4.7.5; extra == 'snowflake'
Provides-Extra: taskiq
Requires-Dist: taskiq==0.12.6; extra == 'taskiq'
Provides-Extra: trio
Requires-Dist: trio-asyncio==0.16.0; (python_version < '3.14') and extra == 'trio'
Requires-Dist: trio==0.34.0; extra == 'trio'
Provides-Extra: uvloop
Requires-Dist: uvloop==0.22.1; extra == 'uvloop'
Provides-Extra: vortex
Requires-Dist: vortex-data==0.86.1; (python_version < '3.15') and extra == 'vortex'
Provides-Extra: winloop
Requires-Dist: winloop==0.6.4; extra == 'winloop'
Provides-Extra: yaml
Requires-Dist: pyyaml==6.0.3; extra == 'yaml'
Provides-Extra: zenoh
Requires-Dist: eclipse-zenoh==1.10.1; extra == 'zenoh'
Description-Content-Type: text/markdown

# silkworm-rs

[![PyPI - Version](https://img.shields.io/pypi/v/silkworm-rs)](https://pypi.org/project/silkworm-rs/)
[![Tests](https://github.com/BitingSnakes/silkworm/actions/workflows/tests.yml/badge.svg)](https://github.com/BitingSnakes/silkworm/actions/workflows/tests.yml)
[![Docs](https://github.com/BitingSnakes/silkworm/actions/workflows/docs.yml/badge.svg)](https://bitingsnakes.github.io/silkworm/)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/silkworm-rs?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/silkworm-rs)

Silkworm is an async-first Python web scraping framework built on
[wreq](https://github.com/0x676e67/wreq-python) and
[scraper-rs](https://github.com/RustedBytes/scraper-rs). It combines a small,
typed Spider/Request/Response API with middleware, output pipelines, and
production crawl controls.

**[Documentation](https://bitingsnakes.github.io/silkworm/)** ·
**[Getting started](https://bitingsnakes.github.io/silkworm/getting-started.html)** ·
**[Examples](https://bitingsnakes.github.io/silkworm/examples.html)** ·
**[API reference](https://bitingsnakes.github.io/silkworm/api/index.html)**

## Highlights

- Async crawling with concurrency, priorities, request deduplication, timeouts,
  and deadlock-free queue backpressure.
- Browser-impersonating HTTP through wreq, with redirects, proxies, cookies,
  retries, throttling, and robots.txt support.
- Push-style typed callbacks using `await self.emit(...)` and
  `await response.follow(...)`.
- Async CSS/XPath selection and optional declarative `Item`, `Text`, and `Attr`
  extraction.
- File, database, cloud, queue, and message-stream pipelines, with batch
  processing available on every built-in pipeline.
- Production controls for failure policies, stop limits, pause/resume, caching,
  graceful shutdown, metrics, and structured crawl statistics.
- Optional CDP, Servo, and OnionLink clients for rendered or onion-service pages.

## Install

Silkworm supports Python 3.13–3.15.

```bash
pip install silkworm-rs
```

With uv:

```bash
uv add silkworm-rs
```

Integrations are installed as optional extras. For example:

```bash
pip install "silkworm-rs[uvloop,polars]"
```

See [Getting Started](https://bitingsnakes.github.io/silkworm/getting-started.html)
for the complete extras and Python-version compatibility table.

## Quick start

```python
from silkworm import HTMLResponse, Response, Spider, run_spider
from silkworm.pipelines import JsonLinesPipeline


class QuotesSpider(Spider):
    name = "quotes"
    start_urls = ("https://quotes.toscrape.com/",)

    async def parse(self, response: Response) -> None:
        if not isinstance(response, HTMLResponse):
            return

        for quote in await response.select(".quote"):
            text = await quote.select_first(".text")
            author = await quote.select_first(".author")
            if text is not None and author is not None:
                await self.emit({"text": text.text, "author": author.text})

        next_link = await response.select_first("li.next > a")
        if next_link is not None and (href := next_link.attr("href")):
            await response.follow(href, callback=self.parse)


run_spider(
    QuotesSpider,
    item_pipelines=[JsonLinesPipeline("data/quotes.jl")],
)
```

Callbacks return `None`; they report items and requests with `emit` and `follow`,
which apply backpressure while the callback is running.

## Command line

Run a spider module or test its parser without writing a runner script:

```bash
silkworm crawl examples/quotes_spider.py -o data/quotes.jl -s max_items=100
silkworm parse https://quotes.toscrape.com/ --spider examples/quotes_spider.py
```

See the [CLI reference](https://bitingsnakes.github.io/silkworm/cli.html) for
configuration, output formats, and exit codes.

## Documentation

| Topic | Guide |
| --- | --- |
| Installation, extras, and first spider | [Getting Started](https://bitingsnakes.github.io/silkworm/getting-started.html) |
| Spider, request, response, selectors, and callbacks | [Core Concepts](https://bitingsnakes.github.io/silkworm/core-concepts.html) |
| Declarative item extraction | [Declarative Extraction](https://bitingsnakes.github.io/silkworm/declarative.html) |
| Engine, HTTP, CDP, Servo, and OnionLink | [Engine and HTTP Client](https://bitingsnakes.github.io/silkworm/engine-and-http.html) |
| Request and response middleware | [Middlewares](https://bitingsnakes.github.io/silkworm/middlewares.html) |
| Output destinations and batch processing | [Pipelines](https://bitingsnakes.github.io/silkworm/pipelines.html) |
| asyncio, rsloop, uvloop, winloop, and Trio | [Runners](https://bitingsnakes.github.io/silkworm/runners.html) |
| Resumable and observable crawls | [Production Crawling](https://bitingsnakes.github.io/silkworm/production.html) |
| Version changes | [Migration Guide](https://bitingsnakes.github.io/silkworm/migration.html) |
| Constraints and workarounds | [Limitations](https://bitingsnakes.github.io/silkworm/limitations.html) |

## Development

```bash
uv venv --python python3.13
uv sync --group dev
just fmt && just lint && just typecheck && just test
```

See the [development workflow](https://bitingsnakes.github.io/silkworm/getting-started.html#development-workflow)
and open an issue or pull request on GitHub.

## Acknowledgements

Silkworm builds on wreq, scraper-rs, fast-h2m, rxml, and optional integrations
including OnionLink and Servo. Thank you to their maintainers and contributors.

## License

MIT. See [LICENSE](LICENSE).
