Modular, Ethical Python Web Crawler
Project description
๐ท๏ธ crawlit - Modular, Ethical Python Web Crawler
A powerful, modular, and ethical web crawler built in Python. Designed for security testing, link extraction, and website structure mapping with a focus on clean architecture and extensibility.
๐ Features
- Modular Architecture: Easily extend with custom modules and parsers
- Ethical Crawling: Configurable robots.txt compliance and rate limiting
- Depth Control: Set maximum crawl depth to prevent excessive resource usage
- Domain Filtering: Restrict crawling to specific domains or subdomains
- Robust Error Handling: Gracefully manage connection issues and malformed pages
- Multiple Output Formats: Export results as JSON, CSV, or plain text
- Detailed Logging: Comprehensive logging of all crawler activities
- Command Line Interface: Simple, powerful CLI for easy usage
- Programmatic API: Use as a library in your own Python code
๐ Requirements
- Python 3.8+
- Dependencies (will be listed in requirements.txt)
๐ ๏ธ Installation
From PyPI (recommended)
# Install the core library
pip install crawlit
# Install with CLI tool support
pip install crawlit[cli]
From Source
# Clone the repository
git clone https://github.com/SwayamDani/crawlit.git
cd crawlit
# Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
๐ Usage
API Documentation
Full API documentation is available in the docs directory. To build and view the documentation:
# Install Sphinx and required packages
pip install sphinx sphinx_rtd_theme sphinxcontrib-napoleon
# Build the documentation
cd docs
make html # On Windows: make.bat html
# View the documentation
# Open docs/_build/html/index.html in your browser
As a Library in Your Python Code
from crawlit import Crawler, save_results, generate_summary_report
# Initialize the crawler with custom parameters
crawler = Crawler(
start_url="https://example.com",
max_depth=3,
internal_only=True,
user_agent="MyCustomBot/1.0",
delay=0.5,
respect_robots=True
)
# Start crawling
crawler.crawl()
# Get and process results
results = crawler.get_results()
print(f"Crawled {len(results)} URLs")
# Save results in different formats
save_results(results, "json", "crawl_results.json", pretty=True)
See the examples/programmatic_usage.py file for a complete example.
Command Line Interface
If you installed with pip install crawlit[cli], you can use the command-line interface:
# Basic usage
crawlit --url https://example.com
# Advanced options
crawlit --url https://example.com \
--depth 3 \
--output-format json \
--output results.json \
--delay 0.5 \
--user-agent "crawlit/1.0" \
--ignore-robots
Command Line Arguments
| Argument | Description | Default |
|---|---|---|
--url, -u |
Target website URL | Required |
--depth, -d |
Maximum crawl depth | 3 |
--output-format, -f |
Output format (json, csv, txt, html) | json |
--output, -O |
File to save results | crawl_results.json |
--pretty-json, -p |
Enable pretty-print JSON with indentation | False |
--ignore-robots, -i |
Ignore robots.txt rules | False |
--delay |
Delay between requests (seconds) | 0.1 |
--user-agent, -a |
Custom User-Agent string | crawlit/1.0 |
--allow-external, -e |
Allow crawling URLs outside initial domain | False |
--summary, -s |
Show a summary of crawl results | False |
--verbose, -v |
Verbose output | False |
--help, -h |
Show help message | - |
๐๏ธ Project Structure
crawlit/
โโโ crawlit.py # CLI entry point
โโโ requirements.txt # Project dependencies
โโโ crawler/ # Core crawler modules
โ โโโ __init__.py
โ โโโ engine.py # Core crawler logic
โ โโโ fetcher.py # HTTP request handling
โ โโโ parser.py # HTML parsing and link extraction
โ โโโ robots.py # Robots.txt parser
โโโ output/ # Output formatters
โ โโโ __init__.py
โ โโโ formatters.py # Output formatting functions
โโโ examples/ # Example usage
โ โโโ programmatic_usage.py # Example of using as a library
โโโ tests/ # Unit and integration tests
โโโ __init__.py
๐ Project Timeline
- May 2025: Initial structure and CLI setup
- June 2025: Core functionality complete (HTTP handling, parsing, domain control)
- June 30, 2025: Project completion target with all core features
๐ค Contributing
Contributions will be welcome after the core functionality is complete. Please check back after June 30, 2025, for contribution guidelines.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Author
Built and maintained by Swayam Dani
Note: This project is under active development with completion targeted for June 30, 2025.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crawlit-0.1.0.tar.gz.
File metadata
- Download URL: crawlit-0.1.0.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c188562dd9f19c68b48f3fc35e91934474043bc8f8f42650816e3df84c4bdde
|
|
| MD5 |
20cb79eac171f15b2e78f355a0eb7be8
|
|
| BLAKE2b-256 |
4c44d4a224a9b0e5afcbb4ae022ae806e51fd37b4405a0dbb734f7cac93196fc
|
File details
Details for the file crawlit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: crawlit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6cd050a35c0ae1eef461d47d82511e96351b222b803c527fcb172aab4f88175
|
|
| MD5 |
6a8d393a6af98e8714caef4f1b86a6cf
|
|
| BLAKE2b-256 |
251e2efdd628886d7d9c80d2298f63a1b7bad3e798b9820a72458349b927fb65
|