Metadata-Version: 2.2
Name: aiofetch
Version: 0.0.4
Summary: Collection of different tools for async web scraping, crawling and parsing
Author-email: Akram Rakhmetulla <akram042006@gmail.com>
Maintainer-email: Akram Rakhmetulla <akram042006@gmail.com>
License: The MIT License (MIT)
        
        Copyright (c) 2025 Akram Rakhmetulla
        
        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.
Project-URL: Homepage, https://github.com/spike1236/aiofetch
Project-URL: Issues, https://github.com/spike1236/aiofetch/issues
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: aiohttp
Requires-Dist: bs4
Requires-Dist: aiofiles

# aiofetch

A Python toolkit for asynchronous web scraping with built-in error tracking and metadata management.

## Features

### Web Processing
- Asynchronous file downloading with progress tracking
- Rate limiting with configurable delays
- Smart retry logic with timeout handling
- Domain-aware crawling with URL validation

### Content Processing
- Flexible HTML content parsing
- Custom selector-based metadata extraction
- Automated link and image extraction
- URL normalization and path handling

### File & Data Management
- Asynchronous file operations
- Concurrent chunk-based downloads
- Smart path handling and file naming
- JSON data management with validation

### Error Handling & Progress Tracking
- Comprehensive error tracking and reporting
- Progress monitoring for long operations
- Detailed logging with configurable outputs
- Operation statistics and summaries

### Metadata Management
- Efficient in-memory caching
- Field-based search functionality
- Automatic metadata indexing
- Structured data validation

## Installation

```bash
pip install aiofetch
```

## Key Components

- **AsyncDownloader**: Parallel file downloading with progress tracking
- **BatchProcessor**: Process items in configurable batches
- **RateLimiter**: Control request frequency
- **MetadataExtractor**: HTML metadata extraction with custom selectors
- **PathHandler**: Path and filename utilities
- **FileIO**: Async/sync file operations
- **BaseCrawler**: Extensible crawler base class with domain validation
- **LoggerFactory**: Enhanced logging with file and console outputs

## Requirements

- Python 3.9+
- aiofiles
- aiohttp
- BeautifulSoup4

## Quick start
```python3
import asyncio
from aiofetch import (
    AsyncDownloader,
    MetadataExtractor,
    ContentParser,
    FileIO
)

async def main():
    # Initialize components
    downloader = AsyncDownloader(concurrent_limit=20)
    parser = ContentParser()
    file_io = FileIO()
    
    # Download files
    urls = [
        ("https://example.com/file1.pdf", "downloads/file1.pdf"),
        ("https://example.com/file2.pdf", "downloads/file2.pdf")
    ]
    await downloader.download_batch(urls)
    
    # Parse HTML content
    html = """<html><body>
        <h1>Title</h1>
        <img src="image.jpg" alt="Test">
    </body></html>"""
    
    # Extract metadata
    extractor = MetadataExtractor()
    metadata = extractor.extract_from_html(html, {
        'title': 'h1',
        'images': ('img', 'src')
    })
    
    # Save results
    await file_io.save_json(metadata, 'output/metadata.json')

if __name__ == "__main__":
    asyncio.run(main())
```

## License

MIT License - see LICENSE file for details

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request or Issue.

## Author

Akram Rakhmetulla ([akram042006@gmail.com](mailto:akram042006@gmail.com))
