How to check Alexa rank in PHP


Back to alexa traffic ranking.


*xelitu    (2010-04-25)
How to check Alexa rank in PHP

Hi,

Here is a small script that will let you check the Alexa rank for any website from your server (PHP needed), google.com is only an example, you can change it as you wish of course.

$url = 'google.com';
$alexa = 'http://www.alexa.com/siteinfo/'.$url;
$data = file_get_contents($alexa);

$start = strpos($data, '<div class="data up">')+119;
$stop = strpos($data,'<div class="label">Alexa Traffic Rank');
$rank = substr($data,$start,$stop-$start);


Quite easy, isn't it?

I hope it will help.



(more options below)

bradleyscott    (2010-09-24 09:26:26)
How to check Alexa rank in PHP

Alexa provides this information in many useful formats, including XML. Using the XML provided by Alexa, we can gain access to Alexa information within our pages. I've created a PHP class to make fetching Alexa data free, quick, and easy. The class comes in a PHP4 version and a PHP5 version.
The Code - PHP4 Version

/* the alexa rank class */
class alexa
{
/* initial vars */
var $xml;
var $values;
var $alexa_address;

/* the constructor */
function alexa($alexa_address,$domain)
{
$this->alexa_address = $alexa_address;
$this->xml = $this->get_data($domain);
$this->set();
}

/* gets the xml data from Alexa */
function get_data($domain)
{
$url = $this->alexa_address.'http://'.$domain;
$xml = file_get_contents($url);
return $xml;
}

/* set values in the XML that we want */
function set()
{
$this->values['rank'] = (preg_match('/POPULARITY URL="[a-z0-9\\-\\.\\/]{1,}" TEXT="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
$this->values['reach'] = (preg_match('/REACH RANK="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
$this->values['linksin'] = (preg_match('/LINKSIN NUM="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
}

/* returns the requested value */
function get($value)
{
return (isset($this->values[$value]) ? $this->values[$value] : '"'.$value.'" does not exist.');
}
}

Copy this code to the clipboard
1/* the alexa rank class */
2class alexa
3{
4 /* initial vars */
5 var $xml;
6 var $values;
7 var $alexa_address;
8
9 /* the constructor */
10 function alexa($alexa_address,$domain)
11 {
12 $this->alexa_address = $alexa_address;
13 $this->xml = $this->get_data($domain);
14 $this->set();
15 }
16
17 /* gets the xml data from Alexa */
18 function get_data($domain)
19 {
20 $url = $this->alexa_address.'http://'.$domain;
21 $xml = file_get_contents($url);
22 return $xml;
23 }
24
25 /* set values in the XML that we want */
26 function set()
27 {
28 $this->values['rank'] = (preg_match('/POPULARITY URL="[a-z0-9\\-\\.\\/]{1,}" TEXT="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
29 $this->values['reach'] = (preg_match('/REACH RANK="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
30 $this->values['linksin'] = (preg_match('/LINKSIN NUM="([0-9]{1,12})"/',$this->xml,$regs) ? number_format($regs[1]) : 0);
31 }
32
33 /* returns the requested value */
34 function get($value)
35 {
36 return (isset($this->values[$value]) ? $this->values[$value] : '"'.$value.'" does not exist.');
37 }
38}

__________

Buy Research papers
Purchase Term papers
Custom Written essays


healthtourism    (2011-06-25 12:17:55)
12 years ago

You can install the widget on your website.

Prostate Cancer Treatment Mexico


*dimugi    (2019-08-01 10:54:52)
4 years ago

How do you think the schism in the rec center would most likely have an effect on politics relationships from the Byzantine empire but also north western the uk later on

yet, near gulf politics approach, while there is seculrization about religion in addition country, Secularism develops the muse as for russian women dating of these concepts, at the same time not they all, But many of them, Presupposing such motif in rustic outdoor. present in far terms, The distinction between them stems from the disturbance involving religious beliefs in worldy affairs read more

political research is far more focused on the insides of hawaii as well as, while items. at all times, how they really fixate the study of a person russian babes office of the state, similar to the obama administration, Legislature, actually judiciary. alternate branches aim for voting routines, politics individuals or groups, associations involving states in the usa (world Relations/Foreign insurance), or variation involving political communities (relative the government). Sociology but is more focused on the health and wellbeing having to do with organizations. assuming they do add the state read more.


See also


ficgs
More websites

You must register to see these links, as this is a collaborative page, then you may change the order of the links by clicking the icons before the titles.



admin
Other websites

The following links might be less relevant, please change their ranks if you find them useful.


 Free Alexa rank checker - checks Alexa and Google ranks in one go
selfseo > alexa rank checker.php

 Code Examples -> A PHP script to check Google pagerank, Technorati data, Alexa data, Google indexed/backlink, Yahoo indexed / backlink, MSN indexed, A...
weberdev > get example 4850

How to build a search query for any N number of words in a search...
Query2Report : Generating Html, Pdf and Csv Reports from SQL...

 PHP Alexa Rank Fetcher
davidwalsh > php alexa rank fetcher xml

/* the alexa rank class */ class alexa { /* initial vars */ var...
but i get error on this simplexml_load_file function, saying...

 Script to check alexa rank, backlinks and indexed pages
forums.digitalpoint > s

Weight 177 - 150,000+ pages indexed 15400 backlinks...
Script to check alexa rank, backlinks and indexed...

 Alexa Rank using PHP Script | ByteChip - The Complete Technology Blog
bytechip > 2010/04/get alexa rank using php

page, but since the rank keeps changing they got to update it often,...
div', activeClass: 'active', linksNav: '',...

  * | Alex Polski Blog
alexpolski > 2008/04/23

 Php code to retrieve your alexa rank « Webdigity – Thoughts on SEO and Web development
webdigity.wordpress > 2007/04/17/php code to retrieve your alexa rank

Crazy Fast cPanel Shared Hosting and FFmpeg Hosting with LiteSpeed...
How to Create Interactive Multiple-choice Quiz in Adobe Flash...

 Alexa Help System • Information
alexa > help/viewtopic.php?f=5&amp;t=13501

 Smart Toolbar Firefox Addon | Alexa Rank
smartpagerank > extension.php

 Check Alexa PageRank, Google/MSN/Yahoo Backlinks
justin cook > wp/2006/12/28/check alexa pagerank googlemsnyahoo backlinks

de script dont work, de error curl lib not, found, so who to added...
How to add a calendar (date picker) to your web...

 get alexa ranking using php code | Wordpressapi.com - Developer Code book
wordpressapi > alexa ranking php code

 Alexa Help System • Information
cn.alexa > help/viewtopic.php?f=5&amp;t=14701

 Build an alexa rank checker - PHP - web tutorials - WebQuirk
webquirk > tutorials/PHP/build an alexa rank checker

 How to Display Alexa Traffic Rank Statistics at Your Website - Developer's Corner - TechMynd
techmynd > alexa traffic rank charts graphs statistics

Monitor Website Weight, Load Time at Different Internet Connections...
How to Display Alexa Traffic Rank Statistics at Your...
Download Free AVG Antivirus Complete Security for Android...

 SEO • Information
top25web > bbs/viewtopic.php?f=28&amp;t=6645&amp;start=0

 Alexa Traffic Rank Button - PHP Tutorial
phpform > board/index.php?topic=3.0

What does:Parse error: syntax error, unexpected '*' in...

 Alexa Rank Check PHP Script. -Power Links - SEO Web Directory
power links > sub alexa rank check

allowing them to provide statistics on web site traffic, as well as...

 How to Check Link Popularity in Google & Yahoo With PHP » Meta Titan
metatitan > php/13

 How to Check Google Page Rank? Script to check Google pagerank and Alexa Ranking
globalguideline > articles/analysis.php?k=PHP script to check Google pagerank

//set this variable to 1 if you wish the URLs of the highlighted...
So this is the end of the second file that is using the first...
Click here to learn about SQL basics and developed...

 PHP Google Page Rank,Alexa Rank,DMOZ Listing,Search Engine Backlink Checker
script.wareseeker > PHP/php google page rank alexa rank dmoz listing search engi

PHP Google Page Rank,Alexa Rank,DMOZ Listing,Search Engine Backlink...
Google Page Rank,Alexa Rank,DMOZ Listing,Google,Yahoo,MSN,...

 Extension:AlexaRank - MediaWiki
mediawiki > wiki/Extension:AlexaRank

This page was last modified on 21 February 2008, at...



Response  
 

Guest name   (option)     Register
Please sum : 4352 + seven  




Trackbacks : If you talked about this article in your blog or website, you may instantly get a backlink 
There's no trackback at the moment.