Skip to main content

Modular, Ethical Python Web Crawler

Project description

๐Ÿ•ท๏ธ crawlit - Modular, Ethical Python Web Crawler

License: MIT Python 3.8+

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crawlit-0.1.0.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crawlit-0.1.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

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

Hashes for crawlit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c188562dd9f19c68b48f3fc35e91934474043bc8f8f42650816e3df84c4bdde
MD5 20cb79eac171f15b2e78f355a0eb7be8
BLAKE2b-256 4c44d4a224a9b0e5afcbb4ae022ae806e51fd37b4405a0dbb734f7cac93196fc

See more details on using hashes here.

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

Hashes for crawlit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6cd050a35c0ae1eef461d47d82511e96351b222b803c527fcb172aab4f88175
MD5 6a8d393a6af98e8714caef4f1b86a6cf
BLAKE2b-256 251e2efdd628886d7d9c80d2298f63a1b7bad3e798b9820a72458349b927fb65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page