SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Article Discussion

    This is an article discussion thread for discussing the SitePoint article, "Track Your Rank Using the Google API"

  2. #2
    SitePoint Enthusiast mikeall's Avatar
    Join Date
    Sep 2003
    Location
    Puerto Escondido, Mexico
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would be good if his demo worked for me.

  3. #3
    SitePoint Guru mattymcg's Avatar
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mike. It works fine for me - did you enter your Google API key when you tested it?

  4. #4
    eCommerce specialist hotnuts21's Avatar
    Join Date
    Apr 2002
    Location
    Aberystwyth, UK
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice little script, saves time. Although the results it returns are interesting. For a site I have that ranks no1 whether i search on google.co.uk or .com, with this script it returns that im ranked no 4. I think this is more an issue with the API though.

    I wrote a similar script that runs daily and collects information about certain keywords, which sites rank well and where they rank. It then stores this info in a database, and plots it to a graph so I can follow the trends. Quite handy although it needs polishing up a little.

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Posts
    418
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there some site where you can track your rankings like this ? I'm not too well in this api thing. Don't have the time to get into it either.

    Kind regards,
    M

  6. #6
    SitePoint Enthusiast roboxooo's Avatar
    Join Date
    Dec 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes , try digitalpoint dot com

  7. #7
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or you could DIY :)

    PHP Code:
    <?php

    function oogle_google($url$kw$pagenum=0)
    {
        
    $gurl "http://www.google.co.uk/search?q=" urlencode($kw) . "&meta=cr%3DcountryUK%7CcountryGB&start=$pagenum";
        
    //print $gurl;
        
        
    preg_match_all('/<a class=l href=(.*?) /si', @implode(file($gurl)), $matches);
            
        for(
    $i 0$i count($matches[0]); $i++) 
        {
            if(
    strstr($matches[1][$i], $url)) 
            {
                if(
    $pagenum == 0
                {
                    echo 
    'position ' $i += 1;
                    return 
    null;
                }
                else 
                {
                    echo 
    'position ' $pagenum += $i;
                    return 
    null;
                }
            }
        }        
        
        if(
    $pagenum <= 100)
        {
            
    oogle_google($url$kw$pagenum += 10);  
        }  
        else 
        {
            echo 
    'X';
            return 
    null;    
        }
        


    ?>

  8. #8
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got some errors with your script Scheisskopf. Here is a modified version.

    PHP Code:
    <?php

    function oogle_google($url$kw$pagenum=0) {
        
    $gurl "http://www.google.com/search?q=" urlencode($kw) . "&start=$pagenum";
        
        
    preg_match_all('/<a class=l href=(.*?) /si', @implode(file($gurl)), $matches);
        
        for(
    $i 0$i count($matches[1]); $i++) {
            
    // echo $matches[1][$i];
            
    if(strstr($matches[1][$i], $url)) {
                if(
    $pagenum == 0) {
                    echo 
    'position ' $i += 1;
                    return 
    null;
                } else {
                    echo 
    'position ' $pagenum += $i;
                    return 
    null;
                }
            }
        }

        if(
    $pagenum <= 100){
            
    oogle_google($url$kw$pagenum += 10);
        } else {
            echo 
    'X';
            return 
    null;
        }
    }

    oogle_google('http://www.domain.com/''domains');

    ?>

  9. #9
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,094
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is a great application.
    but pear:soap??

    I went to go-pear.org and now have PEAR. Also downloaded SOAP.

    so now in my localhost (c:\website on win xp) I now have two directories, PEAR and SOAP as well as the files created by go-pear.

    I was confused as to where these went but managed to fix all of the require errors.

    now I am stuck with (I hope) the final error which is

    Fatal error: Call to undefined method SOAP_Fault::doGoogleSearch() in C:\website\google.php on line 78

    Im sure that I am doing something wrong and this is a bit over my head and was hoping some one could help.


  10. #10
    SitePoint Member
    Join Date
    May 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bernard, I got a: Fatal error: main(): Failed opening required 'SOAP/Client.php' when running your script (I renamed goolgle_api_search.txt to google_api_search.php and uploaded to my server and ran it after chmod'ing to 755...). Any clues?

  11. #11
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,094
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    capitaine,

    I was getting the same error and the only way I got that error fixed was to just run it on localhost (a lot less ftp-ing)

    I went to
    http://go-pear.org/
    and ran the script which automatically installed pear and a few other files - run it within a new dir called PEAR or it will overwrite index.php.

    then downloaded SOAP from
    http://pear.php.net/package/SOAP

    (rename the folder to SOAP which is where you will find Client.php)

    There are also a few modules you will need and the error messages (you will get quite a few - some of the errors require you to change the "require_once" path also) will tell you what packages you will need . . .. for example the "http" (this will be one of the next errors) - search for the packages "http" and you will see a list of them you will need HTTP_Client:and HTTP_WebDAV_Client: (these will go into HTTP dir in SOAP . . . just take the files in the 2 zipped directories and place them into HTTP.

    once you get that the other errors will tell you which additional packages or paths you will need.

    This really is a case of the blind leading the blind as you can tell from the post above yours I have not got it completely working but have gotten past all of the "required" errors

    I think my directory structure is wrong also and am awaiting a reply on it but this should give you some insight.

    This should work the same on a www server once it is sorted out.

  12. #12
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got some errors with your script Scheisskopf. Here is a modified version.
    really?
    Last edited by Scheisskopf; May 18, 2006 at 01:29.

  13. #13
    SitePoint Enthusiast jeffinj's Avatar
    Join Date
    Dec 2005
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know another site where you can check your page rankings.
    www.googlerankings.com

    You need the api code for that too.

  14. #14
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey all,i need help!!!
    i am not able to find the keyword ranking through google api.

    i m using code below.problem is i m not able to inclued 'SOAP/Client.php' file

    <?php
    ini_set("display_errors","1");
    if (isset($_REQUEST['submit'])) {
    // script does not expire.
    set_time_limit(0);
    // If your do not have access to php.ini, set the include path to use the Pear Class.
    //ini_set( 'include_path', '.:/home/yourname/pear:/usr/local/lib/php');

    // PEAR:SOAP Cient Class
    require_once('SOAP/Client.php');
    extract($_REQUEST);
    // $q = urlencode($_REQUEST['q']);
    $start = 0;
    $maxResults = 10;
    $filter = false;
    $restrict = '';
    $safeSearch = false;
    $lr = '';
    $ie = '';
    $oe = '';
    $loop = 'true';
    $output = '';

    echo "Searching your url in Google... <br/>";

    function urlSearch($position, &$result) {
    global $loop;
    global $output;
    global $resultLimit;
    global $maxResults;
    global $desc;
    global $q;
    global $myUrl;

    // Get total results from the search
    $count =$result->estimatedTotalResultsCount;
    // Get the resultElements class
    $elements = $result->resultElements;
    // if searched results reach limit set by you, quit loop
    if ($position == $resultLimit) {
    echo "You have restricted the search results to $resultLimit";
    $loop = false;
    }
    else if ($count > 0) {
    echo "$position records<br/>";
    foreach ($elements as $item) {
    $position++;
    // if the url is found, display it and quit loop
    if (preg_match("/$myUrl/i", $item->URL)) {
    $size = $item->cachedSize;
    $title = $item->title;
    $url = $item->URL;
    $snippet = $item->snippet;
    $desc .= "<p>$title [Cache Size: $size]<br/> <a href=\"$url\" target=\"_blank\">$url</a><br />";
    $desc .= "$snippet</p>";
    $output = "<br /> $count results found. Your url is ranked #{$position} for the keyword \"$q\". It will appear on page ".ceil($position/ $maxResults)." in the Google Search Engine. Your listing will appear as follows: <p>$desc</p>";
    // now exit the while loop
    $loop = false;
    }
    }
    }
    // if google returns no result, quit loop
    else {
    $output = "No results found for the keyword \"$q\"";
    $loop = false;
    }
    }

    while ($loop) {
    // Instantiate the SOAP_WSDL Class.
    $wsdl = new SOAP_WSDL('GoogleSearch.wsdl');
    // Get the WSDL Proxy Class
    $soapclient = $wsdl->getProxy();
    // Start Google API query
    $result = $soapclient->doGoogleSearch($key,$q,$start,$maxResults,$filter,$restrict,$safeSearch,$lr,$ie,$oe);
    // If error occurs
    if (PEAR::isError($result)) {
    $message = $result->message;
    echo "An error occured: $message<p>";
    // pause for 15 secs
    sleep(15);
    // if too much query, quit loop
    if (preg_match("/Daily limit/i", $message)) {
    $loop = false;
    }
    // if invalid key, quit loop
    else if (preg_match("/Invalid/i", $message)){
    $loop = false;
    }
    // if normal timeout message, continue
    else {
    echo "Retrying in 15 secs. <br/>";
    }
    }
    // if no errors, check occurrence of your url in the results.
    else {
    $desc = "";
    // Step up the starting record for the next loop
    $start += $maxResults;
    // the actual ranking
    $position = $start- $maxResults;
    // Search for url
    urlSearch($position, $result);
    }
    }
    // display the final output
    echo $output;

    }
    ?>
    <div align="center"><b>Finding your Google Ranking Using Google API &amp; PEAR:SOAP</b></div>
    <form id="form1" name="form1" method="post" action="">
    <p>Your URL:
    <input type="text" name="myUrl" />
    eg. sitecritic.net <br/>
    Google Api Key:
    <input type="text" name="key" />
    eg. EVwOpLdQFH54lfdgy06Mq1ksCpk/YoYE<br/>
    Key Word:
    <input type="text" name="q" />
    eg. Website Reviews<br />
    Max Results To Search:
    <input name="resultLimit" type="text" value="500" size="4" />
    eg. 500 </p>
    <p>
    <input type="submit" name="submit" value="Submit" />
    </p>
    </form>

  15. #15
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried this feature at
    http://web-developer.sitecritic.net/...api_search.php

    i also entered correct google api. But got following error on searching.

    Warning: preg_match(): Unknown modifier '/' in /home/sitecrit/public_html/web-developer/google_api_search.php on line 56

    Warning: preg_match(): Unknown modifier '/' in /home/sitecrit/public_html/web-developer/google_api_search.php on line 56

  16. #16
    Non-Member
    Join Date
    Jul 2005
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The article is really great. I,ve read this and got many informations from here.

    Thank You,
    Liza

  17. #17
    john
    SitePoint Community Guest
    try without http//
    e.g. mysite.com

  18. #18
    SitePoint Member
    Join Date
    May 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Google UK Results

    I know this is an old thread but I am having trouble getting accurate Google UK results with any of my searches. My results correlate more with .com results restricted to pages from the UK. I wanted to plot the progression of my sites but the data is really no good.

    Is anyone else having this problem?

  19. #19
    SitePoint Member stuartc1's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After testing the demo provided I noticed it can give inaccurate results. In my test I entered a .org domain - the demo script returned the .org.uk equivalent.

    The code: preg_match("/$myUrl/i", $item->URL) could be refined for accuracy.

  20. #20
    SitePoint Wizard silver trophy linkin99's Avatar
    Join Date
    Sep 2005
    Location
    Wisconsin
    Posts
    1,456
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've noticed this too. While the results are close, if I did a manual search on something the results are in fact different.

  21. #21
    max pain
    SitePoint Community Guest
    you get different results because there are many different datacenters (each having results of its own)

  22. #22
    somebody
    SitePoint Community Guest
    The reasons are not different datacenters. They results are not ranked in any way. Try a few searches. There are huge differences.

    Sorry, but the API is no way to check your rank.

  23. #23
    SitePoint Addict noise's Avatar
    Join Date
    Sep 2002
    Location
    Sweden
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should change the encoding of the form request to UTF-8 before querying the google...

    $q = utf8_encode($q);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •