Skip to content

Bhanunamikaze/Agentic-SEO-Skill

Deterministic LLM-first SEO audits for websites, blog posts, and GitHub repositories. Use this when the user asks to "perform SEO analysis", "run SEO audit", "analyze SEO", "check technical SEO", "review schema", "Core Web Vitals", "E-E-A-T", "hreflang", "GEO", "AEO", or GitHub repository SEO optimization. For full/page/repo audits, run bundled scripts for evidence and return prioritized, confidence-labeled fixes.

FileKindSize
SKILL.mdskill md19.4 KB
scripts/__init__.pyscript34 B
scripts/a11y_seo_checker.pyscript3.4 KB
scripts/ai_crawler_policy_matrix.pyscript2.2 KB
scripts/analyze_visual.pyexecutablescript6.5 KB
scripts/anchor_text_audit.pyscript7.7 KB
scripts/answer_block_scanner.pyscript3.9 KB
scripts/article_seo.pyscript27.1 KB
scripts/audit_runner.pyscript3.1 KB
scripts/broken_links.pyscript8.3 KB
scripts/cache_compression_checker.pyscript6.7 KB
scripts/canonical_checker.pyscript3.4 KB
scripts/capture_screenshot.pyexecutablescript4.4 KB
scripts/citation_readiness.pyscript5.1 KB
scripts/collection_page_checker.pyscript4.2 KB
scripts/competitor_gap.pyscript10.2 KB
scripts/content_decay_detector.pyscript6.2 KB
scripts/content_intent_matcher.pyscript5.4 KB
scripts/crawl_audit.pyscript7.2 KB
scripts/critical_request_chain.pyscript4.8 KB
scripts/duplicate_content.pyscript14.0 KB
scripts/eeat_signal_checker.pyscript5.5 KB
scripts/entity_checker.pyscript19.4 KB
scripts/env_loader.pyscript3.6 KB
scripts/external_link_quality.pyscript6.6 KB
scripts/faceted_nav_audit.pyscript3.3 KB
scripts/fetch_page.pyexecutablescript3.6 KB
scripts/finding_verifier.pyscript4.9 KB
scripts/font_audit.pyscript5.9 KB
scripts/freshness_checker.pyscript6.2 KB
scripts/generate_report.pyscript80.7 KB
scripts/github_api.pyscript12.8 KB
scripts/github_community_health.pyscript8.9 KB
scripts/github_competitor_research.pyscript17.2 KB
scripts/github_readme_lint.pyscript14.9 KB
scripts/github_repo_audit.pyscript21.0 KB
scripts/github_search_benchmark.pyscript7.7 KB
scripts/github_seo_report.pyscript32.0 KB
scripts/github_traffic_archiver.pyscript6.3 KB
scripts/github_weekly_scorecard.pyscript4.4 KB
scripts/gsc_checker.pyscript11.4 KB
scripts/hreflang_checker.pyscript24.2 KB
scripts/hreflang_sitemap_validator.pyscript6.4 KB
scripts/image_inventory.pyscript2.8 KB
scripts/image_weight_audit.pyscript4.8 KB
scripts/indexability_matrix.pyscript3.5 KB
scripts/indexnow_checker.pyscript9.4 KB
scripts/internal_links.pyscript10.5 KB
scripts/javascript_render_audit.pyscript2.9 KB
scripts/lcp_subparts.pyscript7.3 KB
scripts/lib/__init__.pyscript46 B
scripts/lib/safe_http.pyscript6.1 KB
scripts/lighthouse_runner.pyscript6.0 KB
scripts/link_profile.pyscript12.5 KB
scripts/llms_txt_checker.pyscript7.5 KB
scripts/llms_txt_generator.pyscript2.9 KB
scripts/local_seo_checker.pyscript3.7 KB
scripts/log_file_analyzer.pyscript6.0 KB
scripts/mobile_render_checker.pyscript6.9 KB
scripts/orphan_pages_from_sitemap.pyscript6.2 KB
scripts/pagespeed.pyscript12.9 KB
scripts/parse_html.pyexecutablescript12.2 KB
scripts/pre_commit_seo_check.shexecutablescript2.9 KB
scripts/product_schema_checker.pyscript4.9 KB
scripts/readability.pyscript14.5 KB
scripts/redirect_backlink_reclaim.pyscript5.7 KB
scripts/redirect_checker.pyscript6.2 KB
scripts/reference_freshness.pyexecutablescript2.9 KB
scripts/repo_docs_site_checker.pyscript5.7 KB
scripts/repo_file_inventory.pyscript3.6 KB
scripts/repo_release_seo.pyscript6.6 KB
scripts/repo_social_preview_checker.pyscript4.1 KB
scripts/repo_topic_suggester.pyscript6.3 KB
scripts/review_schema_checker.pyscript4.0 KB
scripts/rich_results_guard.pyscript3.4 KB
scripts/robots_checker.pyscript7.2 KB
scripts/robots_path_tester.pyscript1.8 KB
scripts/schema_diff.pyscript3.1 KB
scripts/schema_required_props.pyscript8.1 KB
scripts/schema_template_generator.pyscript5.4 KB
scripts/security_headers.pyscript6.8 KB
scripts/seo_common.pyscript14.1 KB
scripts/sitemap_checker.pyscript6.5 KB
scripts/sitemap_generator.pyscript3.4 KB
scripts/social_meta.pyscript8.7 KB
scripts/third_party_script_audit.pyscript4.7 KB
scripts/topical_cluster_mapper.pyscript6.4 KB
scripts/url_quality.pyscript2.5 KB
scripts/validate_schema.pyexecutablescript4.3 KB
scripts/validate_skill_inventory.pyexecutablescript4.8 KB
scripts/video_schema_checker.pyscript3.6 KB
scripts/visual_regression_snapshot.pyscript5.3 KB
scripts/x_robots_header_checker.pyscript2.0 KB

scripts/parse_html.py

View on GitHub
#!/usr/bin/env python3
"""
Parse HTML and extract SEO-relevant elements.

Usage:
    python parse_html.py page.html
    python parse_html.py page.html --url https://example.com
    python parse_html.py --fetch https://example.com --json
"""

import argparse
import json
import os
import re
import sys
from typing import Any, Optional
from urllib.parse import urljoin, urlparse

try:
    from bs4 import BeautifulSoup
except ImportError:
    print("Error: beautifulsoup4 required. Install with: pip install beautifulsoup4")
    sys.exit(1)

try:
    from lib.safe_http import safe_get
except ImportError:
    from scripts.lib.safe_http import safe_get


def _fetch_url(url: str, timeout: int = 20) -> dict[str, Any]:
    """Fetch HTML for direct parsing."""
    response = safe_get(
        url,
        timeout=timeout,
        headers={"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},
    )
    return {
        "url": response.url,
        "content": response.text,
        "headers": dict(response.headers),
        "status_code": response.status_code,
    }


def _schema_items(schema_data: Any) -> list[dict[str, Any]]:
    """Flatten top-level JSON-LD objects and @graph nodes for validation."""
    if isinstance(schema_data, list):
        items: list[dict[str, Any]] = []
        for item in schema_data:
            items.extend(_schema_items(item))
        return items
    if not isinstance(schema_data, dict):
        return []
    items = [schema_data]
    graph = schema_data.get("@graph")
    if isinstance(graph, list):
        items.extend([node for node in graph if isinstance(node, dict)])
    return items


def _rel_contains(value: Any, token: str) -> bool:
    if not value:
        return False
    if isinstance(value, str):
        values = value.lower().split()
    else:
        values = [str(item).lower() for item in value]
    return token in values


def _is_responsive_fill_image(img) -> bool:
    if img.get("data-nimg") == "fill":
        return True
    style = re.sub(r"\s+", "", (img.get("style") or "").lower())
    return "position:absolute" in style and "width:100%" in style and "height:100%" in style


def parse_html(
    html: str,
    base_url: Optional[str] = None,
    headers: Optional[dict[str, Any]] = None,
) -> dict:
    """
    Parse HTML and extract SEO-relevant elements.

    Args:
        html: HTML content to parse
        base_url: Base URL for resolving relative links

    Returns:
        Dictionary with extracted SEO data
    """
    soup = BeautifulSoup(html, "lxml" if "lxml" in sys.modules else "html.parser")
    headers = headers or {}
    header_lookup = {str(k).lower(): v for k, v in headers.items()}

    result = {
        "title": None,
        "meta_description": None,
        "meta_robots": None,
        "x_robots_tag": header_lookup.get("x-robots-tag"),
        "canonical": None,
        "lang": None,
        "charset": None,
        "viewport": None,
        "favicon": None,
        "h1": [],
        "h2": [],
        "h3": [],
        "h4": [],
        "h5": [],
        "h6": [],
        "images": [],
        "links": {
            "internal": [],
            "external": [],
        },
        "pagination": {
            "prev": None,
            "next": None,
        },
        "resource_hints": {
            "preload": [],
            "preconnect": [],
            "dns-prefetch": [],
            "prefetch": [],
            "prerender": [],
        },
        "schema": [],
        "open_graph": {},
        "twitter_card": {},
        "word_count": 0,
        "hreflang": [],
    }

    html_tag = soup.find("html")
    if html_tag:
        result["lang"] = html_tag.get("lang")

    # Title
    title_tag = soup.find("title")
    if title_tag:
        result["title"] = title_tag.get_text(strip=True)

    # Meta tags
    for meta in soup.find_all("meta"):
        name = meta.get("name", "").lower()
        property_attr = meta.get("property", "").lower()
        content = meta.get("content", "")

        if name == "description":
            result["meta_description"] = content
        elif name == "robots":
            result["meta_robots"] = content
        elif name == "viewport":
            result["viewport"] = content

        if meta.get("charset"):
            result["charset"] = meta.get("charset")
        elif meta.get("http-equiv", "").lower() == "content-type":
            charset_match = re.search(r"charset=([^;\s]+)", content, re.I)
            if charset_match:
                result["charset"] = charset_match.group(1)

        # Open Graph
        if property_attr.startswith("og:"):
            result["open_graph"][property_attr] = content

        # Twitter Card
        if name.startswith("twitter:"):
            result["twitter_card"][name] = content

    # Canonical
    canonical = soup.find("link", rel="canonical")
    if canonical:
        href = canonical.get("href")
        result["canonical"] = urljoin(base_url, href) if base_url and href else href

    for icon in soup.find_all("link"):
        rel = icon.get("rel")
        if icon.get("href") and (
            _rel_contains(rel, "icon")
            or _rel_contains(rel, "shortcut")
            or _rel_contains(rel, "apple-touch-icon")
        ):
            result["favicon"] = urljoin(base_url, icon.get("href")) if base_url else icon.get("href")
            break

    # Hreflang
    for link in soup.find_all("link", rel="alternate"):
        hreflang = link.get("hreflang")
        if hreflang:
            result["hreflang"].append({
                "lang": hreflang,
                "href": urljoin(base_url, link.get("href", "")) if base_url else link.get("href"),
            })

    for rel_name in ("prev", "next"):
        page_link = soup.find("link", rel=rel_name)
        if page_link and page_link.get("href"):
            href = page_link.get("href")
            result["pagination"][rel_name] = urljoin(base_url, href) if base_url else href

    for rel_name in result["resource_hints"]:
        for link in soup.find_all("link", rel=rel_name):
            href = link.get("href")
            if href:
                result["resource_hints"][rel_name].append({
                    "href": urljoin(base_url, href) if base_url else href,
                    "as": link.get("as"),
                    "type": link.get("type"),
                    "crossorigin": link.get("crossorigin"),
                })

    # Headings
    for tag in ["h1", "h2", "h3", "h4", "h5", "h6"]:
        for heading in soup.find_all(tag):
            text = heading.get_text(strip=True)
            if text:
                result[tag].append(text)

    # Images
    for img in soup.find_all("img"):
        src = img.get("src", "")
        if base_url and src:
            src = urljoin(base_url, src)
        is_responsive_fill = _is_responsive_fill_image(img)

        result["images"].append({
            "src": src,
            "alt": img.get("alt"),
            "width": img.get("width"),
            "height": img.get("height"),
            "is_responsive_fill": is_responsive_fill,
            "loading": img.get("loading"),
        })

    # Links
    if base_url:
        base_domain = urlparse(base_url).netloc

        for a in soup.find_all("a", href=True):
            href = a.get("href", "")
            if not href or href.startswith("#") or href.startswith("javascript:"):
                continue

            full_url = urljoin(base_url, href)
            parsed = urlparse(full_url)

            link_data = {
                "href": full_url,
                "text": a.get_text(strip=True)[:100],
                "rel": a.get("rel", []),
            }

            if parsed.netloc == base_domain:
                result["links"]["internal"].append(link_data)
            else:
                result["links"]["external"].append(link_data)

    # Schema (JSON-LD) — enhanced with type validation
    DEPRECATED_SCHEMA = {
        "HowTo", "SpecialAnnouncement", "CourseInfo", "EstimatedSalary",
        "LearningVideo", "ClaimReview", "VehicleListing", "PracticeProblems",
    }
    RESTRICTED_SCHEMA = {"FAQPage"}  # government/healthcare only

    for script in soup.find_all("script", type="application/ld+json"):
        try:
            schema_data = json.loads(script.string)
        except (json.JSONDecodeError, TypeError):
            result["schema"].append({
                "error": "invalid_json",
                "raw_snippet": (script.string or "")[:120],
            })
            continue

        items = _schema_items(schema_data)
        for item in items or [{}]:
            schema_type = item.get("@type", "Unknown")
            if isinstance(schema_type, list):
                schema_types = schema_type
                primary_type = next((t for t in schema_type if isinstance(t, str)), "Unknown")
            else:
                schema_types = [schema_type]
                primary_type = schema_type

            status = "active"
            note = ""

            if primary_type in DEPRECATED_SCHEMA:
                status = "deprecated"
                note = f"{primary_type} was deprecated/removed from rich results. Remove or replace."
            elif primary_type in RESTRICTED_SCHEMA:
                status = "restricted"
                note = f"{primary_type} is restricted to government/healthcare authority sites only."

            result["schema"].append({
                "@type": primary_type,
                "@types": schema_types,
                "@id": item.get("@id"),
                "@context": item.get("@context", schema_data.get("@context", "") if isinstance(schema_data, dict) else ""),
                "status": status,
                "note": note,
                "has_context": bool(item.get("@context") or (isinstance(schema_data, dict) and schema_data.get("@context"))),
                "has_type": bool(item.get("@type")),
                "from_graph": item is not schema_data,
                "raw": item,
            })

    # Word count (visible text only)
    for element in soup(["script", "style", "nav", "footer", "header"]):
        element.decompose()

    text = soup.get_text(separator=" ", strip=True)
    words = re.findall(r"\b\w+\b", text)
    result["word_count"] = len(words)

    return result


def main():
    parser = argparse.ArgumentParser(description="Parse HTML for SEO analysis")
    parser.add_argument("file", nargs="?", help="HTML file to parse")
    parser.add_argument("--url", "-u", help="Base URL for resolving links")
    parser.add_argument("--fetch", help="Fetch and parse a URL directly")
    parser.add_argument("--timeout", "-t", type=int, default=20, help="Fetch timeout in seconds")
    parser.add_argument("--json", "-j", action="store_true", help="Output as JSON")

    args = parser.parse_args()

    headers = {}
    final_url = args.url

    if args.fetch:
        try:
            fetched = _fetch_url(args.fetch, timeout=args.timeout)
        except Exception as exc:
            print(f"Error fetching {args.fetch}: {exc}", file=sys.stderr)
            sys.exit(1)
        if fetched.get("error"):
            print(f"Error fetching {args.fetch}: {fetched['error']}", file=sys.stderr)
            sys.exit(1)
        html = fetched.get("content") or ""
        headers = fetched.get("headers") or {}
        final_url = args.url or fetched.get("url") or args.fetch
    elif args.file:
        real_path = os.path.realpath(args.file)
        if not os.path.isfile(real_path):
            print(f"Error: File not found: {args.file}", file=sys.stderr)
            sys.exit(1)
        with open(real_path, "r", encoding="utf-8") as f:
            html = f.read()
    else:
        html = sys.stdin.read()

    result = parse_html(html, final_url, headers=headers)

    if args.json:
        print(json.dumps(result, indent=2))
    else:
        print(f"Title: {result['title']}")
        print(f"Meta Description: {result['meta_description']}")
        print(f"Canonical: {result['canonical']}")
        print(f"H1 Tags: {len(result['h1'])}")
        print(f"H2 Tags: {len(result['h2'])}")
        print(f"Images: {len(result['images'])}")
        print(f"Internal Links: {len(result['links']['internal'])}")
        print(f"External Links: {len(result['links']['external'])}")
        print(f"Schema Blocks: {len(result['schema'])}")
        print(f"Word Count: {result['word_count']}")


if __name__ == "__main__":
    main()
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall