Skip to main content

Grab and recursively parse website sitemaps, robots.txt, and other related files.

Project description

Sitemap Utility Suite

A Python-based utility suite designed to fetch and analyze sitemaps and other well-known files from websites.

Table of Contents

Features

  • Fetch and parse XML sitemaps from websites
  • Recursively traverse sitemap indices
  • Extract sitemap URLs from robots.txt files
  • Fetch common well-known files (robots.txt, humans.txt, security.txt)
  • Robust error handling and logging
  • User-agent spoofing for web requests

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/sitemap-utility-suite.git
    cd sitemap-utility-suite
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    

Installation with documentation dependencies

To install Sitemap Grabber with documentation dependencies:

  1. Ensure you have flit installed:

    pip install flit
    
  2. Install the package with documentation dependencies:

    flit install --deps develop --extras docs
    

For developers who want to contribute to the project:

  1. Install the package with both documentation and development dependencies:
    flit install --deps develop --extras "docs,dev"
    

Alternatively, if you prefer using pip:

pip install -e ".[docs,dev]"

This will install the package in editable mode along with all necessary dependencies for building the documentation and development tools.


Usage

Here's a basic example of how to use the SitemapGrabber:

from sitemap_grabber import SitemapGrabber

# Initialize the SitemapGrabber with a website URL
grabber = SitemapGrabber("https://example.com")

# Fetch all sitemaps
grabber.get_all_sitemaps()

# Print the discovered sitemap URLs
for url in grabber.sitemap_urls:
    print(url)

To fetch well-known files:

from well_known_files import WellKnownFiles

# Initialize the WellKnownFiles with a website URL
wkf = WellKnownFiles("https://example.com")

# Fetch robots.txt
robots_txt = wkf.fetch("robots.txt")
print(robots_txt)

# Fetch security.txt
security_txt = wkf.fetch("security.txt")
print(security_txt)

Components

SitemapGrabber

The SitemapGrabber class is responsible for discovering and fetching XML sitemaps from a given website. It can:

  • Extract sitemap URLs from robots.txt
  • Check common sitemap locations
  • Recursively traverse sitemap indices
  • Handle relative and absolute URLs

WellKnownFiles

The WellKnownFiles class fetches common well-known files from websites, including:

  • robots.txt
  • humans.txt
  • security.txt

It includes caching to avoid redundant requests and can handle various edge cases in HTTP responses.

Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.


For more information or to report issues, please visit the GitHub repository.

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

sitemap_grabber-1.0.1.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

sitemap_grabber-1.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file sitemap_grabber-1.0.1.tar.gz.

File metadata

  • Download URL: sitemap_grabber-1.0.1.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for sitemap_grabber-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6b9065a896a61783acdef713318b2714fc8bfa1d495ca1637984a722c1a6e41d
MD5 8248ad1745c05c0d0d87a2f8f12cf3b8
BLAKE2b-256 5ddf7526c972c628c1678ca9fbc8fded1fe1da924822d9531efe4dfb842bdada

See more details on using hashes here.

File details

Details for the file sitemap_grabber-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sitemap_grabber-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 937c77a002c3e03b592a59d9aeef1ff819af8548e4756cf009e47930489f0205
MD5 bdc47f22b4d0e8c9c47e8896141078dd
BLAKE2b-256 443ef06533f43a190cc5cf1cec39a7b89e84adfbcece8bce01a86032285d978d

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