Вы находитесь на странице: 1из 3

<?php //Script Google Suggest by http://www.seoblackout.com // Auteurs du script : Beunwa http://divioseo.fr/ & Tiger http://www.seoblackout .

com // Contributeurs mrites : Seg http://www.wagablog.com/ & Meuhsli http://www.thugee k.com/ // Url article du script pour bugs, commentaires... : http://www.seoblackout.com /2010/01/27/google-suggest/ ?> <form action="" method="post"> <table><tr><td> Keyword : <textarea name="kw" rows="10"><?=strip_tags($_POST['kw '])?></textarea> </td><td> et <textarea name="mix2" rows="10"><?=strip_tags($_POST['mix2']) ?></textarea> </td><td> <br /> Langue : <select name="lang"> <option value="fr">FR</option> <option value="en">EN</option> </select> <br /> Profondeur : <select name="depth"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> <br /> Alphabet :<input type="checkbox" name="alph" /> </td></tr></table> <br /> <input type="submit" value="Go" /> </form> <?php if(isset($_POST['kw'])){ $lang = strip_tags($_POST["lang"]); if($lang == '') $lang = "fr"; $depth = strip_tags($_POST["depth"]); if($depth == '') $depth = "1"; $kwsd = array(); $kwsd=explode("\n",trim(strip_tags($_POST["kw"]))); foreach ($kwsd as $lst) { if($lst != "\n"){ //mots cles simple ggSuggest($lst, $lang, $depth); //mots cles avec complments $kws2 = array(); $kws2=explode("\n",strip_tags($_POST["mix2"])); foreach ($kws2 as $mix2) { ggSuggest($lst.$mix2, $lang, $depth); } //alphabet

if(strip_tags($_POST["alph"]) == "on"){ $alpha = "a"; while($alpha != "z"){ ggSuggest($lst.' '.$alpha, $lang, $depth ); $alpha = ++$alpha; } } } } } function ggSuggest($kw, $lang, $depth = 1, $inc = 1){ global $tabKw; $tabKw[] = $kw; $url = 'http://www.google.com/complete/search?hl='.$lang.'&js=true&qu='. url encode($kw); if (function_exists('curl_init')) { $header = array( "Accept: text/xml,application/xml,application/xhtml+xml, text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept-Language: fr-fr,fr;q=0.7,en-us;q=0.5,en;q=0.3", "Accept-Charset: utf-8;q=0.7,*;q=0.7", "Keep-Alive: 300"); $ch = curl_init(); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com/'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6 .0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)' ); curl_setopt($ch, CURLOPT_HTTPHEADER, $header ); curl_setopt($ch, CURLOPT_URL, $url); $result=curl_exec ($ch); curl_close ($ch); } else { $result= file_get_contents($url); } preg_match_all('/\["(.*?)",/si', $result, $kwgoogle, PREG_SET_ORDER);//m ot preg_match_all('/\,"(.*?)rsultats",/si', $result, $nbresult, PREG_SET_ORDE R);//nb resultats if ($kwgoogle=='' $inc > $depth) { return $tabKw; }else { $ii = 0; foreach($kwgoogle as $v){ $tk = utf8_decode(strip_tags($v[1])); if(!in_array($tk, $tabKw)){ $tk = str_replace ('\r',"", $tk); $kwr = utf8_decode($nbresult[$ii][1]); if($kwr == "") $kwr = 0; echo $kwr.' ; '.$tk.'<br />'; $ii++;

flush(); ggSuggest($tk, $lang, $depth, $inc+1); } } } return $tabKw; } ?>

Вам также может понравиться