Skip to main content
Alt Text

myrmex

The compact web crawling toolkit.

Unlike full-featured frameworks, myrmex does not implement an entire scraping pipeline. Instead, it focuses exclusively on core crawling functionality. Higher-level scraping logic is left to the specific implementation of your scraper.

If you're looking for a complete scraping framework, consider Scrapy.

myrmex provides a minimal interface through two crawler classes — Crawler and TorCrawler — for regular HTTP crawling and Tor-based anonymous crawling, respectively.

Key Capabilities

  • Asynchronous context management for automatic resource handling
  • Built on aiohttp for HTTP requests
  • Executes synchronous operations using the native asyncio thread pool (non-blocking)
  • Functional-style error handling via Result
  • Configurable per-operation timeouts for robust request management

Installation

Install via pip:

pip install myrmex

Or using uv:

uv add myrmex

Please note that the following libraries will be installed alongside myrmex:

  • aiohttp – for HTTP requests
  • aiohttp-socks – for SOCKS5 proxy support
  • stem – for Tor control port integration
  • result – for functional-style error handling

Configuration

Crawler accepts the following options:

Parameter Type Default Description
timeout int 10 Timeout (in seconds) for HTTP requests.
headers dict None HTTP headers to include with each request.

…and TorCrawler accepts the following options during initialization:

Parameter Type Default Description
address str None SOCKS5 proxy address for routing traffic through Tor.
password str None Control port password for authenticating with the Tor proxy.
timeout int 10 Timeout (in seconds) for HTTP requests.
headers dict None HTTP headers to include with each request.

Usage Example

The example below demonstrates how to fetch your current IP address over the Tor network:

import asyncio
from myrmex import TorCrawler

async def main():
    async with TorCrawler("socks5h://127.0.0.1:9050", password="password") as crawler:
        await crawler.rotate_ip()  # optional: rotates IP before request
        result = await crawler.fetch("http://httpbin.org/ip")
        if result.is_ok():
            print("Current IP:", result.unwrap())

asyncio.run(main())

Tor Setup

Since TorCrawler is strictly associated with Tor network usage, ensure that you have a configured and running Tor instance before using it.

Update your torrc configuration file with the following:

SocksPort 0.0.0.0:9050
ControlPort 0.0.0.0:9051
HashedControlPassword ***

To generate a hashed password:

tor --hash-password your_password

Start Tor manually in the background:

tor &

Metadata

Release files for myrmex 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for myrmex 0.1.5
File Size Uploaded
myrmex-0.1.5.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for myrmex 0.1.5
File Interpreter ABI Platform
myrmex-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / myrmex-0.1.5.tar.gz

Download URL myrmex-0.1.5.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f171bc922ae18a3d88a5178edfe4960cebdfaf23d41578f32b9a499042dbe85c
BLAKE2b-256 checksum
How to use checksums
142bac5dec11b028d4c3b6234de4ef42a234b7f7beee7c4cbf106297df1329a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release files / myrmex-0.1.5-py3-none-any.whl

Download URL myrmex-0.1.5-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cac49a7c41e2218a8aaf5d2bd7d4e3fe5b89f03532eed22a61b3f94aa3f1ff5d
BLAKE2b-256 checksum
How to use checksums
ff768d67bc0a6a7997a26039d52ca6abb31a94d19759a8b07c0b0b23931004f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.18

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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