getButterfly Logo getButterfly code wrangling since 2005

Another great article from MetaTitan, how to check your blog’s link popularity with Google, Yahoo and Alexa. Check the original article or read more to see the code.

// Setting the URL variable
$link = $_GET['url'];

// Google Backlinks
function fetch_google($uri) {
$uri = trim(eregi_replace('http://', '', $uri)); $uri = trim(eregi_replace('http', '', $uri));
$url = ''.$uri;
$v = file_get_contents($url);
preg_match('/of about \<b\>(.*?)\<\/b\>/si',$v,$r);
return ($r[1]) ? $r[1] : '0';

// Yahoo Inlinks
function fetch_yahoo($uri) {
$uri = trim(eregi_replace('http://', '', $uri)); $uri = trim(eregi_replace('http', '', $uri));
$url = ''.$uri.'&bwm=i&bwmf=s&bwmo=&fr2=seo-rd-se';
$v = file_get_contents($url);
preg_match('/of about \<strong\>(.*?) \<\/strong\>/si',$v,$r);
return ($r[1]) ? $r[1] : '0';

// Alexa Rating
function fetch_alexa($uri){
$uri = trim(eregi_replace('http://', '', $uri)); $uri = trim(eregi_replace('http', '', $uri));
$url = '' . urlencode($uri);
$v = file_get_contents($url);
preg_match('/\<popularity url\="(.*?)" TEXT\="([0-9]+)"\/\>/si', $v, $r);
return ($r[2]) ? $r[2] : '0';

// Page Header
echo "<h2>Search Engine Popularity</h2>";

// Display Links and Information
if (isset($link)) {
echo "<strong>URL:</strong> " . $link . "<br />";
echo "<strong>Google Backlinks:</strong> " . fetch_google($link) . "<br />";
echo "<strong>Yahoo Backlinks:</strong> " . fetch_yahoo($link) . "<br />";
echo "<strong>Alexa Rating:</strong> " . fetch_alexa($link) . "<br />";

// Search Form
echo "<br />
<form action=\"linkcheck.php\" method=\"get\">
<input type=\"text\" name=\"url\" />
<input type=\"submit\" />


Subscribe to getButterfly Blog

Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.

If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.

One thought on “How to Check Link Popularity in Google & Yahoo With PHP

  1. Cool info, thanks. I use an SEO extension on my Firefox browser. But I see how I could use PHP and a cron job on my server to automatically email me my stats.


Leave a reply