Skip to content

AI-Powered SEO Content Analyzer | Google Gemini & OpenAI | Smart keyword matching, AI recommendations, CLI with beautiful UI

License

Notifications You must be signed in to change notification settings

cleven12/seo_optimizer

Repository files navigation

SEO Analyzer - AI-Powered Content Optimization Tool

Python Version License: MIT Code style: black Maintenance PRs Welcome GitHub stars Twitter Follow

A powerful Python CLI tool that combines traditional SEO analysis with cutting-edge AI to optimize your web content for search engines. Get actionable insights, AI-powered recommendations, and grammar-safe content improvements.

Features β€’ Installation β€’ Usage β€’ AI Features β€’ Documentation β€’ Contributing


Table of Contents


Overview

SEO Analyzer is an advanced Python CLI tool designed for SEO professionals, content creators, and digital marketers who want to optimize their web content for search engines. It combines traditional SEO analysis with state-of-the-art AI models (Google Gemini & OpenAI GPT-5) to provide intelligent recommendations that boost your search rankings.

Why Choose SEO Analyzer?

  • Keyword-Focused Analysis: Target specific keywords with Google-like matching algorithms
  • AI-Powered Insights: Get intelligent recommendations from cutting-edge AI models
  • Grammar-Safe Optimization: Fix grammar issues without affecting SEO keywords
  • Comprehensive Scoring: Evaluate 40+ SEO factors with weighted scoring
  • Beautiful CLI Output: Rich terminal interface with colors and progress indicators
  • Fast & Efficient: Get complete analysis in seconds
  • Export-Ready: JSON output for automation and integration

Features

Core SEO Analysis

Feature Description
Keyword Analysis Analyzes short-tail and long-tail keywords with intelligent matching
Google-like Matching Smart keyword detection using stemming, variations, and stopword removal
Individual & Cluster Scoring Detailed performance metrics for each keyword and keyword groups
Technical SEO Title tags, meta descriptions, canonical tags, Open Graph validation
Content Quality Keyword density, placement, distribution, and word count analysis
Structure Analysis Heading hierarchy (H1-H6), image alt tags, and content organization
Link Analysis Internal and external link counts with quality assessment

Advanced Features

  • NLP-Powered Matching: NLTK-based tokenization, stemming, and semantic analysis
  • Weighted Scoring System: Configurable weights for different SEO factors
  • Beautiful CLI: Rich terminal output with colors, tables, and panels
  • JSON Export: Machine-readable reports for automation
  • Verbose Mode: Detailed breakdowns for in-depth analysis
  • Fast Analysis: Complete reports in under 10 seconds

AI-Powered Features

NEW! Intelligent Content Optimization

Leverage the power of Google Gemini (FREE) or OpenAI GPT-5 for advanced SEO insights:

1. AI-Powered Recommendations

  • Get 5 specific, actionable SEO recommendations
  • Keyword-focused suggestions tailored to your target keywords
  • Based on current performance scores and content analysis

2. AI-Optimized Meta Tags

  • Title Tag Generation: SEO-optimized titles (50-60 characters)
  • Meta Description Generation: Compelling descriptions (150-160 characters)
  • Keyword-integrated, click-worthy, and search-engine friendly

3. Content Quality Analysis

Evaluate your content across multiple dimensions:

  • Readability Score (1-10): How easy is your content to read?
  • Engagement Potential (1-10): Will readers stay on your page?
  • Keyword Stuffing Risk (1-10): Are you over-optimizing?
  • Content Value (1-10): Does your content provide real value?
  • Keyword Targeting (1-10): How well do you target your keywords?

4. Grammar & Readability (SEO-Safe)

The most unique feature - improve grammar WITHOUT affecting SEO:

  • Grammar Score: Identify grammar issues (1-10 scale)
  • SEO-Preserved Fixes: Grammar corrections that keep ALL keywords intact
  • Improved Title & Meta: Better versions with keywords preserved
  • Readability Tips: Enhance readability without changing keyword density
  • Grammar Suggestions: Top 3 fixes that won't hurt your SEO

Why This Matters: Traditional grammar checkers often remove or change keywords, hurting your SEO. Our AI understands SEO and fixes grammar while preserving keyword density and placement.

Supported AI Models

Provider Model Cost Recommended For
Google Gemini gemini-2.5-flash FREE Everyone (default)
OpenAI gpt-5 Paid Advanced users

Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Internet connection (for webpage analysis)

Step 1: Clone the Repository

git clone https://github.com/cleven12/seo_optimizer.git
cd seo_optimizer

Step 2: Create Virtual Environment

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate

# On Windows:
venv\Scripts\activate

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Download NLTK Data

python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords'); nltk.download('punkt_tab')"

Step 5: Set Up AI Features (Optional)

For AI-powered recommendations, you need an API key:

Option 1: Google Gemini (FREE - Recommended)

  1. Get a FREE API key: https://aistudio.google.com/apikey
  2. Set environment variable:
# On macOS/Linux:
export GEMINI_API_KEY="your-api-key-here"

# On Windows:
set GEMINI_API_KEY=your-api-key-here

# Or add to .env file:
echo "GEMINI_API_KEY=your-api-key-here" > .env

Option 2: OpenAI (Paid)

  1. Get API key: https://platform.openai.com/api-keys
  2. Set environment variable:
# On macOS/Linux:
export OPENAI_API_KEY="your-api-key-here"

# On Windows:
set OPENAI_API_KEY=your-api-key-here

Quick Start

Basic Analysis

python main.py --url "https://example.com" --keywords "seo,optimization,search engine"

With AI Recommendations

python main.py --url "https://example.com" --keywords "seo,optimization" --ai

Export to JSON

python main.py --url "https://example.com" --keywords "python tutorial" --output report.json --ai

Verbose Mode

python main.py --url "https://example.com" --keywords "web development" --verbose --ai

Usage Examples

Example 1: Blog Post Optimization

python main.py \
  --url "https://myblog.com/learn-python" \
  --keywords "learn python,python tutorial,python for beginners" \
  --ai \
  --verbose

Example 2: E-commerce Product Page

python main.py \
  --url "https://shop.com/product/123" \
  --keywords "buy laptop,gaming laptop,best laptop 2025" \
  --output product-seo-report.json \
  --ai

Example 3: Landing Page Analysis

python main.py \
  --url "https://saas.com/landing" \
  --keywords "project management software,team collaboration tool" \
  --ai

Example 4: Batch Analysis (Shell Script)

#!/bin/bash
URLS=(
  "https://example.com/page1"
  "https://example.com/page2"
  "https://example.com/page3"
)

for URL in "${URLS[@]}"; do
  python main.py --url "$URL" --keywords "target keyword" --output "report-$(basename $URL).json" --ai
done

What It Analyzes

Keyword Performance

  • Title tag optimization
  • Meta description optimization
  • Heading tags (H1-H6) usage
  • Keyword density (1-3% optimal)
  • First 100 words placement
  • Content distribution analysis
  • Keyword variations detection

Technical SEO

  • Title length (50-60 chars)
  • Meta description (150-160 chars)
  • Canonical tags
  • Open Graph tags (social sharing)
  • HTTP status validation
  • Mobile-friendly tags

Content Quality

  • Total word count
  • Readability level (AI)
  • Content structure
  • Keyword distribution
  • Engagement potential (AI)
  • Content value score (AI)

Page Structure

  • Heading hierarchy validation
  • H1 count and placement
  • Image alt tag coverage
  • Paragraph structure
  • List usage analysis
  • Content organization

Link Analysis

  • Internal links count
  • External links count
  • Anchor text optimization
  • Link quality assessment
  • Recommended link density

AI Insights (with --ai)

  • 5 actionable recommendations
  • AI-optimized title tag
  • AI-optimized meta description
  • Grammar & readability (SEO-safe)
  • Content quality analysis
  • Keyword targeting score

Architecture

Modular Pipeline Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      CLI Interface Layer                     β”‚
β”‚                    (Rich Terminal Output)                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Orchestrator/Controller                    β”‚
β”‚              (Coordinates Analysis Pipeline)                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚               β”‚               β”‚
          β–Ό               β–Ό               β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Content β”‚    β”‚ Keyword  β”‚    β”‚  NLP     β”‚
    β”‚ Fetcher β”‚    β”‚Processor β”‚    β”‚Processingβ”‚
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
         β”‚              β”‚               β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚              β”‚              β”‚
         β–Ό              β–Ό              β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚Technicalβ”‚    β”‚ Content β”‚    β”‚Structureβ”‚
    β”‚   SEO   β”‚    β”‚Analyzer β”‚    β”‚Analyzerβ”‚
    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜
         β”‚             β”‚              β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   AI Analyzer   β”‚
              β”‚ (Gemini/OpenAI) β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Scoring Engine  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Output Layer   β”‚
              β”‚  (CLI / JSON)   β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

Component Technology Purpose
CLI Interface Rich, argparse User input and formatted output
Content Fetcher requests, BeautifulSoup4 HTML parsing and data extraction
Keyword Processor NLTK NLP operations (stemming, tokenization)
Analysis Modules Plugin architecture Modular SEO analyzers
AI Analyzer Google Gemini / OpenAI AI-powered recommendations
Scoring Engine Custom algorithm Weighted scoring system
Output Layer Rich / JSON CLI rendering and export

βš™οΈ Configuration

Customize analysis behavior by editing src/config.py:

# Keyword Density
OPTIMAL_KEYWORD_DENSITY_MIN = 1.0  # 1%
OPTIMAL_KEYWORD_DENSITY_MAX = 3.0  # 3%

# Title & Meta
OPTIMAL_TITLE_LENGTH_MIN = 50
OPTIMAL_TITLE_LENGTH_MAX = 60
OPTIMAL_META_DESC_LENGTH_MIN = 150
OPTIMAL_META_DESC_LENGTH_MAX = 160

# Content
MIN_WORD_COUNT = 300

# Links
RECOMMENDED_INTERNAL_LINKS_MIN = 3
RECOMMENDED_INTERNAL_LINKS_MAX = 10

# Scoring Weights
KEYWORD_ANALYSIS_WEIGHT = 0.40  # 40%
TECHNICAL_SEO_WEIGHT = 0.20     # 20%
CONTENT_QUALITY_WEIGHT = 0.20   # 20%
STRUCTURE_WEIGHT = 0.10         # 10%
LINK_ANALYSIS_WEIGHT = 0.10     # 10%

Sample Output

πŸ” Analyzing: https://example.com
Focus Keywords: "python tutorial", "learn python", "python for beginners"

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ“Š SEO ANALYSIS REPORT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🎯 OVERALL SEO SCORE: 78/100

╔════════════════════════════════════════════════════╗
β•‘ 🎯 Keyword Cluster Performance: 75/100             β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

πŸ“ˆ Individual Keyword Scores:

βœ… "python tutorial" - 85/100
   β”œβ”€ Title: βœ“ Yes
   β”œβ”€ Meta: βœ“ Yes
   β”œβ”€ H1: βœ“ Yes
   β”œβ”€ Density: 2.1% (optimal)
   └─ First 100 words: βœ“ Yes

⚠️  "learn python" - 70/100
   β”œβ”€ Title: βœ— No
   β”œβ”€ Meta: βœ“ Yes
   β”œβ”€ H1: βœ“ Yes
   β”œβ”€ Density: 1.5%
   └─ First 100 words: βœ“ Yes
      πŸ’‘ Add "learn python" to title tag

βœ… "python for beginners" - 80/100
   β”œβ”€ Title: βœ“ Yes
   β”œβ”€ Meta: βœ“ Yes
   β”œβ”€ H1: βœ— No
   β”œβ”€ Density: 1.8%
   └─ First 100 words: βœ“ Yes
      πŸ’‘ Include "python for beginners" in H1 heading

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

βœ… Technical SEO: 85/100
βœ… Content Analysis: 82/100
βœ… Structure: 75/100
⚠️  Links: 65/100

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ€– AI-POWERED SEO INSIGHTS (Gemini 2.5 Flash)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ“ AI-Optimized Title:
   Learn Python: Complete Tutorial for Beginners in 2025

πŸ“„ AI-Optimized Meta Description:
   Master Python programming with our comprehensive tutorial designed for beginners. Learn syntax, projects, and best practices. Start coding today!

πŸ“Š Content Quality Analysis:
   β”œβ”€ Readability: 8/10
   β”œβ”€ Engagement: 9/10
   └─ Content Value: 8/10

✍️  Grammar & Readability (SEO-Safe):
   β”œβ”€ Grammar Score: 7/10
   β”œβ”€ Issues Found: 5
   └─ SEO Keywords Preserved: βœ“ Yes

   Improved Title (Keywords Preserved):
   Learn Python: The Complete Tutorial for Beginners

   Grammar Fixes:
   β€’ Fix run-on sentence in paragraph 3 (keywords preserved)
   β€’ Add comma after introductory phrase
   β€’ Correct subject-verb agreement in section 2

   Readability Tips:
   β€’ Break long paragraphs into shorter ones
   β€’ Use more transition words between sections

πŸ’‘ AI Recommendations:
   1. Add "learn python" to the title tag for better keyword coverage
   2. Include more internal links to related Python topics (current: 2, recommended: 5-8)
   3. Extend meta description to 155-160 characters for optimal visibility
   4. Add "python for beginners" to the H1 heading
   5. Increase keyword density for "learn python" to 1.5-2% for better targeting

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 TOP RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

1. πŸ”΄ Add "learn python" to title tag
2. πŸ”΄ Increase internal linking (add 3 more links)
3. 🟑 Extend meta description to 155-160 characters
4. 🟒 Include "python for beginners" in H1 heading

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

βœ… Analysis complete! Export with --output to save as JSON

πŸ“š Documentation

Full Documentation

Command Line Reference

usage: main.py [-h] -u URL -k KEYWORDS [-o OUTPUT] [-v] [--ai]

SEO Analyzer - AI-Powered Content Optimization Tool

required arguments:
  -u, --url URL         Target URL to analyze
  -k, --keywords KEYWORDS
                        Comma-separated focus keywords

optional arguments:
  -h, --help            Show this help message and exit
  -o, --output OUTPUT   JSON output file path
  -v, --verbose         Show detailed analysis
  --ai                  Enable AI-powered recommendations (requires API key)

Environment Variables

Variable Description Required
GEMINI_API_KEY Google Gemini API key For AI features
OPENAI_API_KEY OpenAI API key Alternative to Gemini

Roadmap

Completed

  • Core SEO analysis engine
  • Keyword matching with NLP
  • Beautiful CLI output
  • JSON export functionality
  • AI-powered recommendations (Gemini & OpenAI)
  • Grammar analysis (SEO-safe)
  • Content quality evaluation

In Progress

  • Google Search Console integration
  • Competitor comparison analysis
  • Historical tracking dashboard

Planned

  • Semantic similarity with spaCy
  • Multi-language support (ES, FR, DE, IT)
  • Batch URL analysis
  • Web dashboard interface
  • WordPress plugin
  • Browser extension
  • REST API endpoint
  • Slack/Discord bot integration
  • Page speed metrics
  • JavaScript rendering support
  • Image SEO analysis
  • Schema markup validation
  • Backlink analysis
  • SERP position tracking

Contributing

Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.

How to Contribute

  1. Fork the Project

    git clone https://github.com/cleven12/seo_optimizer.git
  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

Development Setup

# Clone and setup
git clone https://github.com/cleven12/seo_optimizer.git
cd seo_optimizer
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt  # For testing

# Run tests
pytest

# Code formatting
black src/
flake8 src/

Contribution Guidelines

  • Write clear, commented code
  • Follow PEP 8 style guide
  • Add tests for new features
  • Update documentation
  • Keep commits focused and atomic

License

Distributed under the MIT License. See LICENSE file for more information.

MIT License

Copyright (c) 2025 Cleven

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...

Support

Get Help

Community


Show Your Support

If you find this project useful, please consider:


Project Stats

GitHub repo size GitHub contributors GitHub issues GitHub pull requests GitHub last commit


Acknowledgments


Author

Cleven


Made with ❀️ by Cleven

⭐ If you find this project useful, please give it a star! ⭐

⬆ Back to Top