mikeyy_
Junior Member
- Oct 17, 2009
- 138
- 83
Hey guys,
I just scripted this up real quick for another post, just wanted to make sure everyone else got the chance to see it.
I just scripted this up real quick for another post, just wanted to make sure everyone else got the chance to see it.
PHP:
<?php
print "Enter domain:\n";
$domain = getInput();
print "\nEnter query (Press enter if none):\n";
$query = getInput();
print "\nEnter number to start from:\n";
$start = getInput();
print "\nEnter how many results to output:\n";
$amount = getInput();
$content = googQuery($domain, $query, $start, $amount);
print "=======================\n";
print "Results.....\n";
print "=======================\n";
preg_match_all('/<a title=".*?" href=(.*?)>/', $content, $matches);
foreach($matches[1] as $match){
print $match."\n";
}
function googQuery($domain, $query, $start, $amount)
{
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
fputs($fp, "GET http://www.google.com/ie?q=site%3A$domain%20" . urlencode($query) . "&num=$amount&start=$start&filter=0 HTTP/1.1\r\n");
fputs($fp, "Host: www.google.com\r\n");
fputs($fp, "User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10\r\n");
fputs($fp, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n");
fputs($fp, "Accept-Language: en-us,en;q=0.5\r\n");
fputs($fp, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n");
fputs($fp, "Connection: close\r\n\r\n");
while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
return $buf;
}
function getInput($length=255)
{
$fr=fopen("php://stdin","r");
$input = fgets($fr,$length);
$input = rtrim($input);
fclose ($fr);
return $input;
}
?>