PHP Rank Checker: Check Your Ranking On Different Search Engines
That's a simple php script I developed many years ago
That’s a simple php script I developed many years ago in order to check websites ranking on several search engines at the same time. Its functioning is a real easy one:
- Digit the site URL you want to check;
- digit a Keyphrase for your search;
- start your search.
I decided to release the code of this simple but useful program as-it-is, under Creative Commons (it's better than keep it unused into my archives).
How Rank Checkers work
Just 3 files with few PHP code lines:
- form.php - send 3 parameters to start your research: HTTP_POST_VARS['url'] the site to check, HTTP_POST_VARS['key'], the research key and TTP_POST_VARS['num'] the highest number results to check;
- search.php – it runs the scanning of all SERP in order to establish sites ranking by source parsing all SERPs found with file_get_contents()method.
- start.html - the results page
The first file contains the form that send the values to the search script (search.php) and display the results page into the proper iframe.
Here it is the code of search.php, with some explanations:
// CONFIG ****************$nomi[1]="Google.it";
$nomi[2]="Yahoo.com";
$nomi[3]="Msn.it";
$nomi[4]="Altavista.com";
$nomi[5]="Lycos.it";
$motori[1]="http://www.google.it/search?as_q=<%key%>&hl=it&num=<%num%>...
$motori[2]="http://search.yahoo.com/search?_adv_prop=web&x=op&ei=...
$motori[3]="http://search.msn.it/results.aspx?q=<%key%>&first=0&count=<%num%>...
$motori[4]="http://www.altavista.com/web/results?itag=wrx&pg=aq&aqmode=s...
$motori[5]="http://cerca.lycos.it/cgi-bin/pursuit?etemp=error&query=<%key%>...
$splitter[1]='<div class=g';
$splitter[2]='<a class=yschttl';
$splitter[3]='<li><h3>';
$splitter[4]="<br class='lb'>";
$splitter[5]='<div style="margin-bottom:25px;">';
$num=$HTTP_POST_VARS['num'];
//************************
I fixed in 3 arrays the main data I need:
- $names[ ] – search engine name
- $engines[ ] – its SERP URL
- $splitter[ ] - string I will use in order to split the SERP source before running the key research matching of its array (the array index that will give me back a positive matching will correspond as well to the site ranking).
And then...
while (list($x,) = each($engines)) {for each engine...
$search_url=str_replace('<%key%>',urlencode($HTTP_POST_VARS['key']),$egines[$x]); $search_url=str_replace('<%num%>', urlencode($num), $search_url);...I can trace the correct SERP URL with all parameters found in the module
$lines = file_get_contents($search_url);$sections = split($splitter[$x], $lines);
$lines = file_get_contents($search_url);
$pos[$names[$x]]=0;
foreach ($sections as $key => $value) {
if (strpos($value, $HTTP_POST_VARS['url'])) {
$pos[$names[$x]]=$key; break;}
}
if ($pos[$names[$x]]==0) {$pos[$names[$x]]="-";}
Then here you have all results:
echo $names[$x]." : ".$pos[$names[$x]];}
Extending its functionality
These are a few ideas to improve it and make it more functional
- Raise the number of engines
- It's enough to insert in all set up arrays: name, SERP URL and the split string (looking into SERP source);
- It's enough to insert in all set up arrays: name, SERP URL and the split string (looking into SERP source);
- Fidelization
- Give the option to receive all results by email;
- Schedule all analysis running (with a Db support) so to send all users an email report;
- Give the option to receive all results by email;
- Test
- You can link search engines name in SERP results so that all users can check it;
- You can link search engines name in SERP results so that all users can check it;
- Pay attention to..
- If suddenly a research doesn’t work, maybe the SERP source code has changed. So, you have to visualize its source by a hand research, looking for a new source string useful also as a splitter for all results.
- To your own system calls, Google needs API Key as a developer parameter. Add URL to Google SERP, the parameter &key=<your api key>
- If suddenly a research doesn’t work, maybe the SERP source code has changed. So, you have to visualize its source by a hand research, looking for a new source string useful also as a splitter for all results.
Tags:
programming
software
seo
ranking
php
rank-checker
opensource
freeware
Daniele Di Gregorio