Skip to main content

Agastya

High-performance web scraping and MongoDB utilities for Python.

Features

  • CustomLogger: Fast, color-coded logging with minimal overhead
  • Record: Lightweight MongoDB document wrapper with state management
  • fetch(): Smart HTTP client with caching, retries, and validation
  • clean_dict(): Comprehensive text/HTML cleaning utilities
  • run_engine(): Adaptive concurrent task executor with auto-scaling threads

Installation

pip install agastya

Quick Start

Basic Usage

from agastya import fetch, CustomLogger, Record

# Initialize logger
logger = CustomLogger(name=__file__)

# Fetch with caching
response = fetch(
    url="https://example.com",
    save_dir="cache",
    filename="page.html",
    max_retries=3
)

# Work with MongoDB records
from pymongo import MongoClient
db = MongoClient()['mydb']
collection = db['items']

doc = collection.find_one({"_id": "123"})
record = Record(doc, collection, logger)

# Mark states
record.mark_done("scraped", meta={"items": 42})
record.mark_fail("parsed", meta={"error": "timeout"})

Configuration

Create a config.py in your project root:

from pymongo import MongoClient

client = MongoClient("mongodb://localhost:27017")
db = client['your_database']

Advanced Features

Smart caching with validation:

response = fetch(
    url="https://example.com/data",
    save_dir="cache",
    filename="data.html",
    valid_rules={
        "required": ["expected text"],
        "forbidden": ["error", "404"],
        "remove": True  # delete invalid cache
    }
)

Concurrent processing:

from agastya import run_engine
from pymongo import MongoClient

db = MongoClient()['mydb']
collection = db['tasks']

def worker(doc):
    # Process document
    print(f"Processing {doc['_id']}")

query = {"status": "pending"}
run_engine(collection, query, worker, THREADS_START=50)

Requirements

  • Python 3.8+
  • requests
  • lxml
  • pymongo
  • urllib3

Development

# Clone repository
git clone https://github.com/yourusername/agastya.git
cd agastya

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

License

MIT License - see LICENSE file for details

Metadata

Release files for agastya 1.2.1

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

Source distribution (sdist)

Source distribution for agastya 1.2.1
File Size Uploaded Provenance
agastya-1.2.1.tar.gz 3.2 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 6.3 kB

Release files / agastya-1.2.1.tar.gz

Download URL agastya-1.2.1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bcd16612ca79fb92605ffbf9d990ded0a67f1a6aec193c9e4449dbd687fbf945
BLAKE2b-256 checksum
How to use checksums
0369495a2caa9fb06ca52161b801bbcdd5a832103cca81109633b80c1b0f9131
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / agastya-1.2.1-py3-none-any.whl

Download URL agastya-1.2.1-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a325c5cb004da2e61dc7b1fa824e83dcac135056656a78ffb1974e9bd014fa9
BLAKE2b-256 checksum
How to use checksums
fbc4f38bf76862d280ec42b54510d1093befb1fbe0ade28150c4b5910ec75a03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Security for agastya 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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