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.

SiteJuicer is fully cross-platform, working seamlessly on Windows, macOS, and Linux systems.

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.

Managing PyPI Tokens

# Save your PyPI token for package publishing
sitejuicer --pypi-token pypi-YOUR_TOKEN_HERE

# Clear a previously saved PyPI token
sitejuicer --clear-pypi-token

# Generate a .pypirc file using your saved token
sitejuicer --generate-pypirc

This feature allows you to securely store your PyPI token and automatically generate a valid .pypirc file for publishing packages. The token is stored securely at ~/.sitejuicer/config.ini with restricted permissions, and the generated .pypirc file will have appropriate permissions to protect your credentials.

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.6.tar.gz (926.2 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.6-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sitejuicer-0.2.6.tar.gz
  • Upload date:
  • Size: 926.2 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.6.tar.gz
Algorithm Hash digest
SHA256 d28e563b8d754b90f896c10331897352adacbe93374c25d00313d7577dcd005e
MD5 6ad990134aaa1a303b85b14d789875a1
BLAKE2b-256 165744fd24161609a8af4216a4cea3cd2b92afd38d1657c096181ce3f2dfb7f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sitejuicer-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dc65a9f8ae73487ec88c21658808c40ba12756eba282bb1a3cec6f9761e3aac5
MD5 e710ab6bc4e7fefa61f987079dd60a79
BLAKE2b-256 d45fcc292736c2a0574df50811496aee538129ee1e322cd3b3fbde4942e6cc5c

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