Skip to main content

InSite

by Bloom Research

InSite is a Python module for crawling websites and compiling PDFs of their pages. It's primarily intended for crawling code documentation websites to download PDFs for offline knowledge supplementation and RAG implementations in LLMs.

Features

  • Efficient parallel web crawling with Playwright
  • Smart link discovery even for non-standard link formats
  • Content filtering with positive and negative filter patterns
  • Proper media rendering before PDF conversion
  • Hierarchical PDF organization based on URL structure
  • PDF merging capability for creating comprehensive documentation

Installation

pip install insite

Requirements

  • Python 3.7+
  • Playwright
  • pypdf

After installation, you'll need to install the Playwright browsers:

playwright install

Usage Examples

Basic Web Crawling

import asyncio
from insite import InsiteScraper

async def main():
    # Create a scraper for a documentation site
    scraper = InsiteScraper("https://docs.python.org/3/")
    
    # Get all links on the site
    links = await scraper()
    
    print(f"Found {len(links)} links")
    
asyncio.run(main())

Converting Pages to PDFs

import asyncio
from insite import InsiteScraper, InsiteProcessor

async def main():
    # First, get all links from a site
    scraper = InsiteScraper("https://docs.python.org/3/library/")
    links = await scraper()
    
    # Then convert them to PDFs
    processor = InsiteProcessor(output_dir="python_docs")
    successes, failures = await processor.process_links(links)
    
    print(f"Successfully created {successes} PDFs")
    
    # Optionally create a single merged PDF
    master_file = processor.merge_to_masterfile("python_library_docs.pdf")
    print(f"Created master file: {master_file}")
    
asyncio.run(main())

Filtering Content

import asyncio
import re
from insite import InsiteScraper, InsiteProcessor

async def main():
    # Only include specific sections and exclude others
    positive_filters = ['/library/']  # Only library documentation 
    negative_filters = [
        '/archives/',                 # Skip archived content
        re.compile(r'\.(jpg|gif)$'),  # Skip images
    ]
    
    scraper = InsiteScraper(
        "https://docs.python.org/3/",
        max_concurrent=10,  # Use 10 concurrent workers
        debug=True,         # Enable debug output
        positive_filters=positive_filters,
        negative_filters=negative_filters
    )
    
    links = await scraper()
    
    # Process the filtered links
    processor = InsiteProcessor(output_dir="python_library_docs")
    await processor.process_links(links)
    
asyncio.run(main())

Command-Line Usage

The module includes a command-line tool for quick documentation scraping:

python -m insite.cli --url https://docs.python.org/3/ --output python_docs --max-pages 100 --create-master

License

GNU General Public License - GPLv3

Metadata

Release files for insite 0.1.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 insite 0.1.1
File Size Uploaded
insite-0.1.1.tar.gz 25.1 kB Details

Built distribution (wheel)

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

Total release size: 50.7 kB

Release files / insite-0.1.1.tar.gz

Download URL insite-0.1.1.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6fa23aabe35e94e860412f45c8eb8fd9aaf8d056da122b241a02d415bfce7a61
BLAKE2b-256 checksum
How to use checksums
756dafe505c2bfdd24ce6da1c68bc29922a18b95f2f80783b2b6f2affc8527ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Release files / insite-0.1.1-py3-none-any.whl

Download URL insite-0.1.1-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ceee48c3c2b52b93189e45ac83a85c4dc43b2869e21739c428cf9f0195e07956
BLAKE2b-256 checksum
How to use checksums
bc656c0eacfc9f5ed01a1ef47d8e49b1e5df3a5ed591d712af679d3d8359a3d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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