Captain Midnight
Newbie
- Sep 30, 2009
- 31
- 7
I munged together a php program to rotate through a list of proxy servers and hit Google Suggest for results based on a keyword.
For example:
The reason why I'm posting it here is because I read someone else has a script here that didn't work very well and the suggestions were to also rotate through proxy severs. Anyway, I though I would share what I munged together:
For example:
Code:
# php gs.php tools
tools
tools of the trade
tools plus
tools for sale
tools of the mind
tools and toys
tools4cheap
tools independence mo
toolsnow
tools for working wood
The reason why I'm posting it here is because I read someone else has a script here that didn't work very well and the suggestions were to also rotate through proxy severs. Anyway, I though I would share what I munged together:
PHP:
<?php
/*
* gsuggest - Will use a proxy file to randomize connections for google suggestions results.
*
* Create a proxy.list file in the formation of
* USERNAME:PASSWORD@IP:PORT
* USERNAME:PASSWORD@IP:PORT
*
* Usage: gsuggest <keyword>
*
* Captain Midnight - 03/24/14
*
*/
$proxyuse="true";
function gsuggest(&$keyword)
{
if (isset($keyword) && $keyword !== "") {
$getcontents=file_get_contents("proxy.list");
$proxydetails=explode("\n",$getcontents);
$n=-1;
for($gets=0;$gets<=count($proxydetails);$gets++)
{
$exp=explode(":",$proxydetails[$gets]);
$expa=explode("@",$exp[1]);
$n++;
$authentication_keywords[$n]["username"] = $exp[0];
$authentication_keywords[$n]["password"] = $expa[0];
$authentication_keywords[$n]["ip"] = $expa[1];
$authentication_keywords[$n]["port"] = $exp[2];
}
$get_auth_keys = $authentication_keywords[array_rand($authentication_keywords)];
$user = $get_auth_keys[username];
$pass = $get_auth_keys[password];
$ips = $get_auth_keys[ip];
$port = trim($get_auth_keys[port]);
$encode=$user.":".$pass;
/*
echo "++++++++++++++++\nDEBUG\n++++++++++++++++\nUSER = $user\nPASS = $pass\nIP = $ips\nPORT = $port\nENCODE = $encode\n";
*/
/* $url = "http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=$keyword"; */
$url = "http://clients1.google.com/complete/search?output=toolbar&hl=en&q=$keyword";
$str = str_replace(" ", "+",$url);
/* if($_REQUEST['proxyuseset']) */
if (isset($proxyuse) && $proxyuse == "true") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $str);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, $port);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $ips);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $encode);
$data = (curl_exec($ch));
curl_close($ch);
} /* proxyset */
else {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $str);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$ips= " ";
}/* noproxyset */
$xml = simplexml_load_string("$data");
foreach ($xml->children() as $child) {
foreach ($child->suggestion->attributes() as $dta) {
echo $dta."\n";
}
}
} /* keyword set */
} /* function */
gsuggest($argv[1]);
?>