1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function google_search_api($args, $referer = 'http://localhost/testing/', $endpoint = 'web')
{
$url = "http://ajax.googleapis.com/ajax/services/search/".$endpoint;
if ( !array_key_exists('v', $args) )
$args['v'] = '1.0';
//$args['key']="ABQIAAAArMTuM-CBxyWL0PYBLc7SuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT-uD75NXlWUsDRBw-8aVAlQ29oCg";
//$args['userip']=$_SERVER['REMOTE_ADDR'];
$args['rsz']='8';
$url .= '?'.http_build_query($args, '', '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// note that the referer *must* be set
curl_setopt($ch, CURLOPT_REFERER, $referer);
$body = curl_exec($ch);
curl_close($ch);
//decode and return the response
echo "";
return json_decode($body,true);
}
$query= $_GET['var1'];
//echo "Results for: $query<br />-----<br />";
$res = google_search_api(array('q' => $query));
$pages=$res['responseData']['cursor']['pages'];
$nres=0;
$res = google_search_api(array('q' => $query,'start'=>$rez['responseData']['cursor']['pages'][0]['start']));
echo '<div>LINKE:'.urldecode($res['responseData']['results'][0]['url']).'</div>';
$ausgabe=urldecode($res['responseData']['results'][1]['url']);
//echo '<div>LINK:'.$ausgabe.'</div>';
	include_once('ganon.php');
	//PHP4 users, make sure this path is correct!
	//Only keep everything between body tags, delete the rest.
	$html = file_get_dom($ausgabe);
	$html->select('"!DOCTYPE"', 0)->delete();
	$html->select('head', 0)->delete();
	$html->select('body', 0)->detach(true);
	$html->select('html', 0)->detach(true);
	//Minified version
	HTML_Formatter::minify_html($html);
	echo "$html\n";
	
	 // Center all the links inside a document which start with "http://"
	// and print out the new HTML
	foreach($html('a[href ^= "http://"]') as $element) {
		$element->clear();
	}
echo $html;