Best Black Hat Forum

Full Version: [VIP] Gscraper - Google Scraper [CodeBank BlackHatDigest Version]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Instruction:
Put this up on a file on your server.
Call it like this:
yourscriptname.php?keywords
PHP Code:
<?php
function text_between($start,$end,$string) {
if (
$start != '') {$temp explode($start,$string,2);} else {$temp = array('',$string);}
$temp explode($end,$temp[1],2);
return 
$temp[0];
}

function 
getHttp($url)
{
$userAgent 'Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6';

// make the cURL request to $target_url
$ch curl_init();
curl_setopt($chCURLOPT_USERAGENT$userAgent);
curl_setopt($chCURLOPT_URL,$url);
curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
curl_setopt($chCURLOPT_AUTOREFERERtrue);
curl_setopt($chCURLOPT_RETURNTRANSFER,true);
curl_setopt($chCURLOPT_TIMEOUT10);

$htmlcurl_exec($ch);
if (!
$html)
{
echo 
"<br />cURL error number:" .curl_errno($ch);
echo 
"<br />cURL error:" curl_error($ch);
exit;
}
return 
$html;
}

function 
gsscrape($keyword) {
$keyword=str_replace(" ","+",$keyword);
global 
$kw;
$url='http://clients1.google.com/complete/search?hl=en&q='.$keyword;
$data getHttp($url);
$data=explode('[',$data,3);
$data=explode('],[',$data[2]);
foreach(
$data as $temp) {
$kw[]= text_between('"','"',$temp);
}
}

# just use yourscriptname.php?keywords
if ($_SERVER['QUERY_STRING']!='') {
gsscrape($_SERVER['QUERY_STRING']);
foreach (
$kw as $keyword) {
gsscrape($keyword);
}
}
echo 
'Url;Results<br>';
#all results are in array $kw...
foreach($kw as $keyword) {
if (
$keyword !='')
{
$url 'http://www.google.com/search?q='.urlencode($keyword);
$html=getHttp($url);
$abc str_replace('of about <b>'''strstr($html'of about <b>'));
echo 
'<a href="'.$url.'">'.$keyword.'</a>;'.substr($abc0strpos($abc'</b>')).'<br />';
}
}
?>