1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP script to check current position on Google

Discussion in 'PHP & Perl' started by mate73, May 6, 2011.

  1. mate73

    mate73 Junior Member

    Joined:
    Jul 16, 2010
    Messages:
    110
    Likes Received:
    184
    Occupation:
    Self-employed student
    Location:
    Wherever the trail may lead
    I recently built my own system in which I keep track of all my niche sites. Unfortunately I'm not able to find a PHP script which I can include and check all the sites position for specific keywords. I know there are software and free services but I want to collect all of this information automatically in my own system.

    I've tried a bunch of different I found on Google but none of them worked. Any suggestions for where I can find a working one?
     
  2. davids355

    davids355 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 25, 2011
    Messages:
    8,796
    Likes Received:
    6,345
    Home Page:
    Why not build one?
     
  3. mate73

    mate73 Junior Member

    Joined:
    Jul 16, 2010
    Messages:
    110
    Likes Received:
    184
    Occupation:
    Self-employed student
    Location:
    Wherever the trail may lead
    Unfortunately I just know the most basic stuff in PHP. Enough to build a site from scratch and access mysql but not enough to accomplish this. Since there are so many free services out there I thought there must be some free scripts floating around on a forum or blog.
     
  4. davids355

    davids355 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 25, 2011
    Messages:
    8,796
    Likes Received:
    6,345
    Home Page:
    Webmasterconsole has an article that's lists about 10 tools - both paid and free that do what you are after, take a look there.

    If you get stuck, I would be willing to write one but would charge a fee.
     
  5. zelma143

    zelma143 Power Member

    Joined:
    Jun 25, 2010
    Messages:
    571
    Likes Received:
    37
    Occupation:
    PHP programmer,Bot maker,iMacro script maker
    I guess your looking for
    google serp


    right??
     
  6. AdsMakesSense

    AdsMakesSense Regular Member

    Joined:
    Jun 23, 2011
    Messages:
    383
    Likes Received:
    25
    You can easily build one by grabbing data with cURL and parsing the fetched data.
    You can also search such related keywords, and find a similair script.
     
  7. mate73

    mate73 Junior Member

    Joined:
    Jul 16, 2010
    Messages:
    110
    Likes Received:
    184
    Occupation:
    Self-employed student
    Location:
    Wherever the trail may lead
    Unfortunately I've tried more than 15 different versions and spent countless of hours looking for a working one.
     
  8. AdsMakesSense

    AdsMakesSense Regular Member

    Joined:
    Jun 23, 2011
    Messages:
    383
    Likes Received:
    25
    Well, if you have no chances looking for a working one, why not save your hours and fire a freelancer to do the job for you. ;)
     
  9. VIC SEO

    VIC SEO Elite Member

    Joined:
    Feb 19, 2010
    Messages:
    2,156
    Likes Received:
    363
    Gender:
    Male
    Occupation:
    SEO Specialist
    Location:
    iSynergyMedia
    Home Page:
    If you've already found such script, then modify it according to your needs and integrate it with your system. otherwise, hire a freelancer
     
  10. andey

    andey Newbie

    Joined:
    Jul 1, 2011
    Messages:
    8
    Likes Received:
    2
    Occupation:
    Rails Developer
    Location:
    Miami | Toronto
    thats exactly what i would of done. CURL to login into google webmaster tools and grab the info you need
     
  11. #Arby#

    #Arby# Newbie

    Joined:
    May 20, 2011
    Messages:
    42
    Likes Received:
    4
    whatpageofsearchamion dot com this is very nice, its from 'iamnotagoodartist' who does some really nice scripts.

    The site does any countries version of google and the first 10 pages. If you want it to do more than 10 you can just contact the developer and ask. Once you have the script/tool you can use it as much as you like.
     
  12. hi.imandrew

    hi.imandrew Junior Member

    Joined:
    Nov 22, 2009
    Messages:
    159
    Likes Received:
    42
    Location:
    Arkansas, USA
    something I just put together.

    PHP:
    <?php
    set_time_limit
    (0);
    $results 0;
    function 
    getlinks($url) {
     
    $data=open_page($url);
     if (
    stristr($data,"did not match any documents")){
      return 
    0;
      
    //Nothing left to search..
     
    }
     if (
    stripos($data,"Google does not serve more than 1000")){
      return 
    0;
      
    //Reached Limit
     
    }
     if (
    stripos($data," we have omitted some entries")){
      return 
    0;
      
    //Search Complete
     
    }
     if (
    stripos($data,"sorry.google.com")){
      return 
    0;
      
    //Google Temp Banned Search Phrase
     
    }
     
    preg_match_all('/(href|src)\=(\"|\')[^\"\'\>]+/i',$data,$media);
     unset(
    $data);
     
    $data=preg_replace('/(href|src)(\"|\'|\=\"|\=\')(.*)/i',"$3",$media[0]);
     return 
    $data;
    }
    function 
    open_page($url,$proxy=""){
     
    $ch curl_init();
     
    curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5");
     
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
     
    curl_setopt($chCURLOPT_CONNECTTIMEOUT20);
     
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
     
    curl_setopt($chCURLOPT_URL$url);
     
    $page curl_exec($ch);
     return 
    $page;
    }
    function 
    scan($query,$start="",$searchurl){
     global 
    $results;
     
    $url "http://www.google.com/search?hl=en&rls=en&q=$query&start=$start";
     
    $urls getlinks($url);
     foreach (
    $urls as $read){
      if (!
    strstr($read,"google") && !strstr($read,"youtube") && (@$read{4} == ":")){
       
    $results++;
       print 
    $read."<br />";
           
    flush();
        
    ob_flush();
       
    //use for less strict comparison
       
    if (stristr($read,$searchurl)){ 
       
    //use for strict comparison
       //if ($read == $searchurl){
        
    return $results
       }
      }
     }
    }
    function 
    serp($keyword,$url){
     
    $i 0;
     
    $pages 100
     
    $pages $pages 10;
     for (
    $i 0$i <= $pages$i++) {
      
    $serp scan(urlencode($keyword),$i,$url);
      if (
    $serp 0){ return $serp; }
      
    $i $i 9;
     }
    }
    $kw "blackhat seo";
    $url "http://www.blackhatworld.com/";
    //note that http:// and www. is important in comparison.
    print "$kw : ".serp($kw,$url)."/1000";
    ?>
     
    • Thanks Thanks x 2
  13. 1337WuLF

    1337WuLF Senior Member Premium Member

    Joined:
    Jan 3, 2011
    Messages:
    919
    Likes Received:
    370
    Occupation:
    IM
    Location:
    On a rock in space
    Thanks. I'll give this a test. (On my iPod currently)
     
  14. matthew1471

    matthew1471 Newbie

    Joined:
    Jul 6, 2010
    Messages:
    15
    Likes Received:
    1
    To be honest, you're probably better off just paying the monthly subscription for an established tracker.

    The time and effort it takes to code and manage your own is daft compared to the $10 a month for someone else to do it.
     
  15. davids355

    davids355 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 25, 2011
    Messages:
    8,796
    Likes Received:
    6,345
    Home Page:
    Agreed!!
     
  16. risefromdeath

    risefromdeath Power Member

    Joined:
    Jul 1, 2009
    Messages:
    650
    Likes Received:
    107

    Please dont put me on fire :D