Montag, 25 August 2025

Top 5 diese Woche

Ähnliche Tutorials

Keyword Checker für Google

Dieses Php Script ermöglicht es, eine Domain und ein Keyword einzugeben und zu prüfen, auf welcher Position die Domain bei Google für dieses Keyword erscheint.

Funktionsweise

  • Das Script schickt eine Anfrage an Google und liest die Ergebnisse der Suchergebnisseite (SERP) aus.
  • Es durchsucht die Links auf der Ergebnisseite und prüft, ob die angegebene Domain enthalten ist.
  • Wird die Domain gefunden, gibt das Script die Position zurück.
  • Falls die Domain nicht in den ersten Treffern vorkommt, wird eine entsprechende Meldung ausgegeben.
<?php
// Keyword Checker – Google Ranking
$result = "";
if (isset($_GET['keyword']) && isset($_GET['domain'])) {
    $keyword = urlencode(trim($_GET['keyword']));
    $domain  = trim($_GET['domain']);

    if ($keyword && $domain) {
        $userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0 Safari/537.36";
        $url = "https://www.google.com/search?q=$keyword&num=100&hl=de";

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $html = curl_exec($ch);
        curl_close($ch);

        preg_match_all('/<a href="\/url\?q=(https?:\/\/[^&]+)&/i', $html, $matches);

        $rank = -1;
        if (!empty($matches[1])) {
            $position = 1;
            foreach ($matches[1] as $link) {
                if (stripos($link, $domain) !== false) {
                    $rank = $position;
                    break;
                }
                $position++;
            }
        }

        if ($rank > 0) {
            $result = "<div class='success'>
                <h2>Ergebnis</h2>
                <p>Die Domain <b>$domain</b> steht für das Keyword <b>".urldecode($keyword)."</b> 
                aktuell auf <span class='highlight'>Platz $rank</span> in den Google-Ergebnissen (Top 100).</p>
            </div>";
        } else {
            $result = "<div class='error'>
                <h2>Ergebnis</h2>
                <p>Die Domain <b>$domain</b> ist für das Keyword <b>".urldecode($keyword)."</b> 
                <span class='highlight'>nicht in den Top 100</span> bei Google gelistet.</p>
            </div>";
        }
    }
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <title>Google Keyword Checker</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0; padding: 0;
            background: #f5f6fa;
            color: #2f3640;
        }
        header {
            background: #273c75;
            color: #fff;
            padding: 20px;
            text-align: center;
        }
        header h1 { margin: 0; font-size: 28px; }
        main {
            max-width: 700px;
            margin: 30px auto;
            background: #fff;
            padding: 25px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        }
        form {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        label {
            font-weight: bold;
        }
        input[type=text] {
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 6px;
            width: 100%;
        }
        input[type=submit] {
            padding: 12px;
            border: none;
            border-radius: 6px;
            background: #44bd32;
            color: #fff;
            font-size: 16px;
            cursor: pointer;
            transition: 0.3s;
        }
        input[type=submit]:hover {
            background: #4cd137;
        }
        .success, .error {
            margin-top: 25px;
            padding: 20px;
            border-radius: 8px;
        }
        .success {
            background: #dff9fb;
            border: 2px solid #44bd32;
        }
        .error {
            background: #f5f6fa;
            border: 2px solid #e84118;
        }
        .highlight {
            font-weight: bold;
            color: #e84118;
        }
        footer {
            margin-top: 40px;
            background: #2f3640;
            color: #dcdde1;
            text-align: center;
            padding: 15px;
            font-size: 14px;
        }
        footer a {
            color: #00a8ff;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <header>
        <h1>Google Keyword Checker</h1>
        <p>Finde heraus, auf welchem Platz deine Domain für ein bestimmtes Keyword bei Google steht</p>
    </header>
    <main>
        <form method="GET">
            <div>
                <label for="keyword">Keyword:</label>
                <input type="text" name="keyword" id="keyword" placeholder="z.B. Immobilien Frankfurt" required>
            </div>
            <div>
                <label for="domain">Domain:</label>
                <input type="text" name="domain" id="domain" placeholder="z.B. beispiel.de" required>
            </div>
            <input type="submit" value="Prüfen">
        </form>
        <?php if ($result) echo $result; ?>
    </main>
    <footer>
        © <?php echo date("Y"); ?> <a href="https://dreamcodes.net" target="_blank">Dreamcodes.net</a> – Alle Rechte vorbehalten
    </footer>
</body>
</html>
Vorheriges Tutorial
Nächstes Tutorial

Hier etwas für dich dabei?