from Google Ranking by Luigi Rosa
Check the ranking of a web page in Google

[position]=googleranking()
function [position]=googleranking()
clc;close all;
disp('The ranking of your web page depends on the keywords you have chosen');
disp('but also on the selected language.');
disp('Insert en for english language. Other possible choices are available here');
disp('http://www.google.com/language_tools?hl=en');
disp('Also the number of results for page has a small impact on final result');
disp('but in most cases it is negligible.');
disp('This value has to be not greater than 100.');
disp('For faster results you may limit your search to a given number.');
disp('This value can not be greater than 1000 results.');
disp(' ');
disp(' ');
disp('Luigi Rosa');
disp('Via Centrale 35');
disp('67042 Civita Di Bagno');
disp('L''Aquila - ITALY');
disp('mobile +39 320 7214179');
disp('email luigi.rosa@tiscali.it');
disp('website http://www.advancedsourcecode.com');
disp(' ');

prompt = {'Insert the domain or URL of your website (eg. google.com or geocities.com/mysite)',...
    'Insert the keyword(s) to list the sites for','Language en=english, it=italian, fr=french, de=german.',...
    'For faster results you may limit your search to the this number',...
    'Number of results per page. This parameter has a small impact on final ranking.'};
title  = 'Google Rankings - Searching parameters';
lines  = 1;
def    = {'','','en','100','10'};
answer = inputdlg(prompt,title,lines,def);

URL      = answer{1};
words    = answer{2};
language = answer{3};
results  = answer{4};
blocco   = answer{5};

if strcmp(results,'')==1
    results = 100;
else
    results  = str2num(results);
end
if results > 1000
    results = 1000;
end
blocco = str2num(blocco);
if blocco > 100
    blocco = 100;
end

% URL     = inputdlg('Insert the domain or URL of your website (eg. google.com or geocities.com/mysite)');
% URL     = URL{1};
% words   = inputdlg('Insert the keyword(s) to list the sites for');


L    = length(words);
pos0 = 1;
cont = 1;
if L>1
    for ii=2:L
        if strcmp(words(ii),' ') == 1
            pos1 = ii-1;
            parole{cont} = words(pos0:pos1);
            cont = cont+1;
            pos0 = pos1+2;
        end
    end
    if pos0<L
        parole{cont} = words(pos0:L);
        cont+1;
    end
else
    parole{cont}=words;
    cont = cont+1;
end
cont = 1;
numero = length(parole);
for ii=1:numero
    if strcmp(parole{ii},'') ||  strcmp(parole{ii},' ') ||  ...
            strcmp(parole{ii},'  ') ||  strcmp(parole{ii},'   ')
    else
        keywords{cont} = parole{ii};
        cont = cont+1;
    end
end
num = length(keywords);
% results = inputdlg('For faster results you may limit your search to the this number');
% results = results{1};
% results = str2num(results);
%-------------------------------------------------
% blocco   = 10;
stopsearch = 0;
avanzo   = mod(results,blocco);
ricerche = (results-avanzo)/blocco;
query = 'q=';
query = strcat(query,keywords{1});
if num>1
    for jj=2:num
        query = strcat(query,'+',keywords{jj});
    end
end
for ii = 1:ricerche
    if stopsearch==0
        indirizzo = strcat('http://www.google.com/search?','hl=',language,'&',...
            query,'&num=',num2str(blocco),'&start=',num2str((ii-1)*blocco));
        html = urlread(indirizzo);
        [pos,stopsearch]  = trovastringa(html,URL);
        if stopsearch == 0
            if pos>0
                position = (ii-1)*blocco+pos;
                disp('The web page');
                disp(URL);
                disp('has this ranking with Google.Com');
                disp(position);
                disp('using the following keywords');
                disp(words);
                disp(strcat('Selected language: ',language));
                return;
            else
                disp(strcat('Scanned:',num2str(ii*blocco),' URLs'));
            end
        end
    end
end
if avanzo>0 && stopsearch==0
    indirizzo = strcat('http://www.google.com/search?','hl=',language,'&',...
        query,'&num=',num2str(avanzo),'&start=',num2str(ricerche*blocco));
    html = urlread(indirizzo);
    [pos,stopsearch]  = trovastringa(html,URL);
    if stopsearch == 0
        if pos>0
            position = ricerche*blocco+pos;
            disp('The web page');
            disp(URL);
            disp('has this ranking with Google');
            disp(position);
            disp('using the following keywords');
            disp(words);
            disp(strcat('Selected language: ',language));
            return;
        else
            disp(strcat('Scanned:',num2str(ricerche*blocco+avanzo),' URLs'));
        end
    end
end
position = 0;
if stopsearch==0
    disp(' ');
    disp('The web page');
    disp(URL);
    disp('has NOT been found');
    disp('using the following keywords');
    disp(words);
else
    disp(' ');
    disp('No web page has been found using the following keywords');
    disp(words);
end





Contact us at files@mathworks.com