Here’s a simple PHP script to check the position of a website for a given keyword on Google:

<?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;

?>

This script takes a keyword and a website URL as input parameters, fetches the Google search results for that keyword, and then checks the position of the given website URL in those search results. It returns the position if the website is found, or a message indicating that the website is not found in the top 100 results. Keep in mind that this script uses simple file retrieval methods which might not work in all environments due to security restrictions or network configurations. Additionally, scraping search engine results may violate their terms of service, so use it responsibly and consider using APIs provided by search engines for such purposes.

Comments (0)

There are no comments here yet, you can be the first!

Leave a Reply

Your email address will not be published. Required fields are marked *


Choose and Buy Proxy

Datacenter Proxies

Rotating Proxies

UDP Proxies

Trusted By 10000+ Customers Worldwide

Proxy Customer
Proxy Customer
Proxy Customer flowch.ai
Proxy Customer
Proxy Customer
Proxy Customer