以下は、Google で特定のキーワードに対する Web サイトの位置を確認するための簡単な PHP スクリプトです。

<?php

function checkKeywordPosition($keyword, $websiteUrl) {
    $googleUrl = "http://www.google.com/search?q=" . urlencode($keyword) . "&num=100";
    $page = file_get_contents($googleUrl);
    
    // Check if the page was fetched successfully
    if ($page === FALSE) {
        return "Error: Unable to fetch Google search results.";
    }

    // Find the position of the website in search results
    $position = strpos($page, $websiteUrl);
    
    // If the website is found, return its position
    if ($position !== FALSE) {
        // Google starts indexing from 1 instead of 0
        return "The website is found at position " . ($position + 1);
    } else {
        return "The website is not found in the top 100 results.";
    }
}

// Example usage
$keyword = "your keyword here";
$websiteUrl = "your website URL here";

$result = checkKeywordPosition($keyword, $websiteUrl);
echo $result;

?>

このスクリプトは、キーワードとウェブサイトの URL を入力パラメータとして受け取り、そのキーワードの Google 検索結果を取得し、それらの検索結果における指定されたウェブサイトの URL の位置を確認します。ウェブサイトが見つかった場合は位置を返し、ウェブサイトが上位 100 件の結果に見つからない場合はメッセージを返します。このスクリプトは、セキュリティ制限やネットワーク構成により、すべての環境で機能するわけではない単純なファイル取得方法を使用していることに注意してください。また、検索エンジンの結果をスクレイピングすると、利用規約に違反する可能性があるため、責任を持って使用し、そのような目的で検索エンジンが提供する API の使用を検討してください。

コメント (0)

まだコメントはありません。あなたが最初のコメントを投稿できます!

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


プロキシの選択と購入

データセンター・プロキシ

プロキシのローテーション

UDPプロキシ

世界中の10,000以上の顧客から信頼されています

代理顧客
代理顧客
代理顧客 flowch.ai
代理顧客
代理顧客
代理顧客