Skip to main content

Convert URLs to markdown using Jina Reader

Project description

SiteJuicer 🧃

SiteJuicer Banner

PyPI version Python Versions License: MIT Downloads

Extract clean, readable content from any website with one command

InstallationQuick StartFeaturesDocumentationExamplesContributing

📖 Overview

SiteJuicer is a powerful command-line utility that converts web content to clean, readable formats like Markdown, HTML, and JSON using Jina Reader. It helps extract valuable content from websites while removing clutter like ads, navigation menus, and other distractions.

Perfect for: Content extraction, web scraping, research, offline reading, and data collection.

✨ Features

  • 📝 Clean content extraction - Remove ads, navigation menus, and other distractions
  • 🔄 Multiple output formats - Convert to Markdown, HTML, or JSON
  • 🖼️ Image extraction - Download and save images from the page (optional)
  • 🔗 Link extraction - Identify and list all links in the content (optional)
  • 📚 Table of contents - Generate a TOC based on headings (optional)
  • 📊 Batch processing - Process multiple URLs at once from a CSV or text file
  • 🌐 API server - Run as a local API server with FastAPI
  • 🖥️ Web UI - Use the graphical interface with Streamlit
  • 🔑 API Key Support - Use your own Jina Reader API key for enhanced features

🚀 Quick Start

# Install
pip install sitejuicer

# Convert a URL to markdown (saved as {title}.md)
sitejuicer https://example.com

# Specify an output format
sitejuicer https://example.com --format html

📦 Installation

# Install from PyPI
pip install sitejuicer

# Optional UI components
pip install "sitejuicer[ui]"

Installation with Optional Components

# For HTML conversion
pip install sitejuicer[html]

# For API server
pip install sitejuicer[server]

# For web UI
pip install sitejuicer[ui]

# For all features
pip install sitejuicer[all]

📋 Usage

Basic Usage

# Convert a URL to markdown (output will be saved to {title}.md)
sitejuicer https://example.com

# Specify an output filename
sitejuicer https://example.com my-output

# Specify output format
sitejuicer https://example.com --format html
sitejuicer https://example.com --format json

Using API Keys

# Save a Jina Reader API key for enhanced features
sitejuicer --api YOUR_API_KEY_HERE

# Clear a previously saved API key
sitejuicer --clear-api

When an API key is configured, SiteJuicer will automatically use it to access the Jina Reader API with enhanced features. If there's an issue with the API key, SiteJuicer will gracefully fall back to the public service.

API keys must be in the format jina_XXXXXXXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXXXXX and are stored securely at ~/.sitejuicer/config.ini with restricted permissions.

Output Format Options

# Apply a template to the output
sitejuicer https://example.com --template blog

# Download and include images locally
sitejuicer https://example.com --include-images

# Specify a directory for downloaded images
sitejuicer https://example.com --include-images --image-dir ./my-images

Content Filtering Options

# Extract only the main content
sitejuicer https://example.com --main-content-only

# Include only specific HTML elements
sitejuicer https://example.com --include-elements p,h1,h2,h3,img

# Exclude specific HTML elements
sitejuicer https://example.com --exclude-elements aside,nav,footer

Batch Processing

# Process URLs from a text file (one URL per line)
sitejuicer --batch urls.txt --output-dir ./converted

# Process URLs from a CSV file
sitejuicer --batch data.csv --output-dir ./converted

🌐 API Server Mode

# Start the API server on the default port (8000)
sitejuicer --server

# Start on a custom port
sitejuicer --server --port 5000

Once started, you can access the API documentation at http://localhost:8000/docs

🖥️ Web UI Mode

# Start the web UI
sitejuicer --ui

This will launch a Streamlit-based web interface at http://localhost:8501

🔄 How It Works

SiteJuicer uses the Jina Reader API to extract clean content from web pages. The processing pipeline includes:

  1. Fetching the web content using the Jina Reader API
  2. Optional content filtering to extract only the main content
  3. Optional image downloading and reference updating
  4. Optional link extraction and listing
  5. Optional table of contents generation
  6. Formatting and saving the content in the desired format (Markdown, HTML, or JSON)

🧩 Programmatic Usage

SiteJuicer can also be used programmatically in your Python scripts:

from sitejuicer.core import fetch_content, format_markdown, save_markdown

# Fetch content from a URL with options
result = fetch_content(
    "https://example.com", 
    options={
        "main_content_only": True,
        "include_images": True,
        "image_dir": "images/",
        "api_key": "jina_2caa021406de46c7837bc05cce50e14d_qcv8AqU_xS_fCtKz3nJ2qS5IcDk"  # Optional: use your Jina Reader API key
    }
)

# Extract content and title from the result
content = result["content"]
title = result["title"]
url = result["url"]

# Format as markdown with options
markdown = format_markdown(
    content, 
    url=url, 
    title=title
)

# Save to a file with specific format
save_markdown(
    markdown, 
    "example.md", 
    url, 
    title, 
    output_format="markdown"
)

See the examples/usage_example.py file for a complete example.

🔌 API Integration

SiteJuicer integrates with the Jina Reader API to process web content. Key details:

  • Endpoint: https://r.jina.ai/{url}
  • Authentication: Bearer token with format Bearer jina_XXXXXXXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXXXXX
  • Response: JSON object with processed content in requested format
  • Error Handling: Graceful fallback to public service when API is unavailable or authentication fails

For detailed information about the API integration and authentication, see:

📄 License

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

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.


Created with ❤️ by Jake Rains

If you find SiteJuicer useful, consider starring the repository or buying me a coffee.

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

sitejuicer-0.2.2.tar.gz (924.9 kB view details)

Uploaded Source

Built Distribution

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

sitejuicer-0.2.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file sitejuicer-0.2.2.tar.gz.

File metadata

  • Download URL: sitejuicer-0.2.2.tar.gz
  • Upload date:
  • Size: 924.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for sitejuicer-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3466c4fe587399e2d1e9ef4a52ef7da74937d7517b4c14ebb51e43276f887222
MD5 f759ae68cb62489b6e230f6231076c91
BLAKE2b-256 6b126c0172a327201fb48cd518f0673e9765985491d0a961e82b921b3c7458d5

See more details on using hashes here.

File details

Details for the file sitejuicer-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: sitejuicer-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for sitejuicer-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4a539ad463b67a4fd7aa3f572bb467835bf52ae580db1b331367671acb59c9c5
MD5 91a6a4bec520f08b1fe13e2b261b6e55
BLAKE2b-256 0b1e9b59ac276e89faea749315fa0fa5ee7a04da6441a8b8d98f069b8f61b661

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