To get the alexa ranking
1.
<?php
2.
3.
/**
4.
* Get Stats from Alexa.com
5.
* @author Seo Sonar
6.
* @copyright www.seosonar.com Free for non-commercial use
7.
* @link http://www.seosonar.com/blog/category/alexa
8.
*/
9.
class api_alexa
10.
{
11.
var $popularity;
12.
var $reach;
13.
var $inlinks;
14.
15.
/**
16.
* Get the alexa details for a domain
17.
*
18.
* @param string $domain
19.
* @return bool
20.
*/
21.
public function getDetails($domain)
22.
{
23.
if(!$html = file_get_contents(
24.
"http://alexa.com/xml/dad?url=$domain"))
25.
return false;
26.
27.
// alexa rank
28.
if (preg_match('/POPULARITY URL="[a-z0-9\\-\\.\\/]{1,}" '.
29.
'TEXT="([0-9]{1,12})"/', $html, $regs))
30.
$this->popularity = (int) $regs[1];
31.
32.
// alexa reach
33.
if (preg_match('/REACH RANK="([0-9]{1,12})"/',
34.
$html, $regs))
35.
$this->reach = (int) $regs[1];
36.
37.
// alexa inlinks
38.
if (preg_match('/LINKSIN NUM="([0-9]{1,12})"/',
39.
$html, $regs))
40.
$this->inlinks = (int) $regs[1];
41.
42.
return true;
43.
}
44.
}
45.
?>
Wednesday, April 9, 2008
Subscribe to:
Post Comments (Atom)
1 comment:
Very helpful. Wandering on net for long time to do this. You made a fullstop. Thanks yaar
Post a Comment