- Complete AI-powered website brochure generator - Includes pyproject.toml and uv.lock for dependency management - Features web scraping, AI content generation, and brochure creation - Ready for deployment and further development
7.2 KiB
Website Brochure Generator
An AI-powered tool that automatically generates professional brochures from any website. The tool analyzes website content, extracts relevant information, and creates beautifully formatted brochures using OpenAI's GPT models.
Features
- 🌐 Website Analysis: Automatically scrapes and analyzes website content
- 🤖 AI-Powered: Uses OpenAI GPT-4o-mini for intelligent content generation
- 📄 Professional Output: Generates markdown-formatted brochures
- 🌍 Multi-Language Support: Translate brochures to any language using AI
- 🎨 Beautiful Output: Rich terminal formatting and native Jupyter markdown rendering
- ⚡ Streaming Support: Real-time brochure generation with live updates
- 🖥️ Multiple Interfaces: Command-line script and interactive Jupyter notebook
- 📓 Interactive Notebook: Step-by-step execution with widgets and examples
Prerequisites
- Python 3.8 or higher
- OpenAI API key
- Jupyter notebook environment (for notebook usage)
Installation
Option 1: Using uv (Recommended)
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone or download the project
cd Website_brochure_generator
# Install dependencies with uv
uv sync
# Activate the virtual environment
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Option 2: Using pip
# 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
Option 3: Using pip with pyproject.toml
# Install in development mode
pip install -e .
# Or install with optional dev dependencies
pip install -e ".[dev]"
Setup
-
Get your OpenAI API key:
- Visit OpenAI API Keys
- Create a new API key
-
Set up environment variables: Create a
.envfile in the project directory:OPENAI_API_KEY=your_api_key_here
Usage
Option 1: Jupyter Notebook (Recommended for Interactive Use)
-
Open the notebook:
jupyter notebook website_brochure_generator.ipynb -
Run the cells step by step:
- Configure your API key
- Try the interactive examples
- Use the widget interface for easy brochure generation
-
Features in the notebook:
- Interactive widgets for URL input and options
- Step-by-step examples with explanations
- Custom functions for advanced usage
- Save brochures to files
- Multiple language translation examples
- Quick website analysis tools
- Custom brochure generation with focus areas
- Comprehensive troubleshooting guide
Option 2: Command Line Interface
# Basic usage
python website_brochure_generator.py https://example.com
# The tool will prompt you to choose:
# 1. Display mode: Complete output OR Stream output
# 2. Translation: No translation OR Translate to another language
Option 3: Python Script
from website_brochure_generator import create_brochure, stream_brochure, translate_brochure
# Create a complete brochure
result = create_brochure("https://example.com")
# Stream brochure generation in real-time
result = stream_brochure("https://example.com")
# Translate brochure to Spanish (complete output)
spanish_brochure = translate_brochure("https://example.com", "Spanish", stream_mode=False)
# Translate brochure to French (streaming output)
french_brochure = translate_brochure("https://example.com", "French", stream_mode=True)
Programmatic Usage
from website_brochure_generator import Website, get_links, create_brochure, translate_brochure
# Analyze a website
website = Website("https://example.com")
print(f"Title: {website.title}")
# Get relevant links
links = get_links("https://example.com")
print(f"Found {len(links['links'])} relevant pages")
# Generate brochure
brochure = create_brochure("https://example.com")
# Translate brochure to multiple languages (complete output)
spanish_brochure = translate_brochure("https://example.com", "Spanish", stream_mode=False)
german_brochure = translate_brochure("https://example.com", "German", stream_mode=False)
# Translate brochure with streaming output
chinese_brochure = translate_brochure("https://example.com", "Chinese", stream_mode=True)
How It Works
-
Website Scraping: The tool scrapes the target website and extracts:
- Page title and content
- All available links
- Cleaned text content (removes scripts, styles, etc.)
-
Link Analysis: Uses AI to identify relevant pages for the brochure:
- About pages
- Company information
- Careers/Jobs pages
- News/Blog pages
-
Content Aggregation: Scrapes additional relevant pages and combines all content
-
Brochure Generation: Uses OpenAI GPT-4o-mini to create a professional brochure including:
- Company overview
- Services/Products
- Company culture
- Career opportunities
- Contact information
-
Translation (Optional): If translation is requested, uses AI to translate the brochure to the target language while:
- Maintaining markdown formatting
- Preserving professional tone
- Keeping proper nouns and company names intact
- Ensuring natural, fluent translation
Output
The tool generates markdown-formatted brochures that include:
- Company Overview: Summary of the business
- Services/Products: What the company offers
- Company Culture: Values and work environment
- Career Opportunities: Job openings and company benefits
- Contact Information: How to reach the company
Dependencies
Core Dependencies
openai>=1.0.0- OpenAI API clientpython-dotenv>=1.0.0- Environment variable managementrequests>=2.25.0- HTTP requests for web scrapingbeautifulsoup4>=4.9.0- HTML parsingrich>=13.0.0- Beautiful terminal output (for command-line usage)ipywidgets>=8.0.0- Interactive widgets (for Jupyter notebook)
Development
Setting up development environment
# Install with dev dependencies
uv sync --extra dev
# or
pip install -e ".[dev]"
Running tests
pytest
Code formatting
black website_brochure_generator.py
Type checking
mypy website_brochure_generator.py
Troubleshooting
Common Issues
-
ImportError: No module named 'rich'
- Make sure you've installed all dependencies:
pip install -r requirements.txt
- Make sure you've installed all dependencies:
-
OpenAI API Key Error
- Verify your API key is set in the
.envfile - Check that your API key has sufficient credits
- Verify your API key is set in the
-
Website Scraping Issues
- Some websites may block automated requests
- The tool uses a standard User-Agent header to avoid basic blocking
-
Display Issues
- For command-line: Make sure Rich is properly installed:
pip install rich - For Jupyter: Make sure ipywidgets is installed:
pip install ipywidgets - Some terminals may not support all Rich features
- For command-line: Make sure Rich is properly installed:
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions, please open an issue on the project repository.