Hi Guys, I have been running SERP scripts on one of my sites, but all the sudden the Google Ranking tools has stopped working. I am sure on what is wrong in the code for Google, both Yahoo and MSN works fine. but not G. Can anybody suggest what is prob in the script below. ------------------------ <?php if ($_GET['url'] != '') { if ($_GET['keyword'] != '') { $keywords[0] = $_GET['keyword']; $url = $_GET['url']; $keyword_input = $_GET['keyword']; } } elseif ($_POST['url'] != '') { if (strpos($_POST['keyword'],"\n")) { $keywords = str_replace("\n",",",$_POST['keyword']); $keywords = explode(",",$keywords); } else { $keywords[0] = $_POST['keyword']; } $keyword_input = $_POST['keyword']; $url = $_POST['url']; } $i = 0; if ($keywords[$i] != '') { while ($keywords[$i] != '') { $keyword_implode = str_replace(' ','+',$keywords[$i]); $fetch_url = "http://www.google.com/search?num=50&q=" . $keyword_implode . "&btnG=Search"; ob_start(); include_once($fetch_url); $page = ob_get_contents(); ob_end_clean(); $page = str_replace('<b>','',$page); $page = str_replace('</b>','',$page); //preg_match('/008000\">(.+)<\/font><nobr>/i', $page, $match); preg_match_all('/<font color=#008000>(.*)<\/font>/', $page, $match); $r = 0; $position = '0'; while ($match[0][$r] != '') { if ($position == '0') { if (strpos($match[0][$r],$url)) { $position = $r+1; } } $r++; } $google_position = $position; --------------------------------- The above code searches Google for ranking on a particular keyword. But for some days now it isnt showing up. Can anybody suggest !
2 suspicions... 1. it seems that your script is scraping the results page - maybe google has changed their format slightly... and some of the anchors you are using have changed? 2. i have noticed that for google, after a couple of pages, it sometimes seem to be able to suspect that the search is performed by a script/robot instead of a human... it then pops up image verification which will definitely confuse your script... i have a similar script for msn - check out my signature...
Well my tool is here, which has Yahoo and MSN along with Google.. Its only the results from Google that is getting retrived.