<?php
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
 
 	$opendb=new mydb();
	require_once('inc/char_set.php');
	include_once("inc/simple_html_dom.php"); //加载simple_html_dom.php文件
	//$ggscstr='http://www.baidu.com/s?wd=wire+mesh';
	
	$keywords="wire mesh";
	$keywords1=str_replace("","+",$keywords);
	$ggscstr='https://www.google.com/search?q='.$keywords1.'';
	$html=file_get_html($ggscstr); //加载html
	 $dom=new simple_html_dom();//new simple_html_dom对象 
	 $dom->load($html); //加载html
	 //搜索结果 <h3><a style="display:none" href="/aclk?sa=L&amp;ai=DChcSEwi2wJe9mcnbAhVHJCsKHZhoAeUYABADGgJzZg&amp;sig=AOD64_09O9MqHNYoad_4Xv578IgO93yaPg&amp;q=&amp;ved=0ahUKEwjJpJG9mcnbAhWMEbwKHZDvDkQQ0QwIugE&amp;adurl=" id="n1s3p3c0"></a><a class="V0MxL r-i0zpN5FhmBLg" href="http://www.chinawirenetting.com/wire-mesh/stainless-steel-wire-mesh.html" id="vn1s3p3c0" onmousedown="return google.arwt(this)" ontouchstart="return google.arwt(this)" data-preconnect-urls="http://www.chinawirenetting.com/" data-prefetch-urls="http://www.chinawirenetting.com/system/js/jquery.js,http://www.chinawirenetting.com/css/demo.css,http://www.chinawirenetting.com/js/modernizr.custom.97074.js" jsl="$t t-r1glFWqNI5A;$x 0;">Stainless Steel Wire Mesh | Stainless Steel Wire Netting‎</a></h3>
	 
	//分页 <a aria-label="Page 2" class="fl" href="/search?q=wire+mesh&amp;ei=NycdW4mtFYyj8AWQ37ugBA&amp;start=10&amp;sa=N"><span class="csb ch" style="background:url(/images/nav_logo242.png) no-repeat;background-position:-74px 0;width:20px"></span>2</a>
	//$dom->load($html);
	$i=0;
	foreach($dom->find('H3') as $e)   // H3 a 是GG搜索结果
	{
		$i++;
		echo $e->innertext . '<br><br>';  
		// echo $newhref."<br/>";
		$getstr=$e->innertext;
		if(strpos($getstr,$keywords)===flase)$i++;
		 
	}
	
	foreach($dom->find('a[aria-label=Page]',0)  as $e) 
	{
		echo $e->href . '<br><br>';  
		// echo $newhref."<br/>";
	}
	
	if($i==0) echo "没找到".$keywords; else echo "关键词".$keywords."关键词在".$i."位";
	$dom->clear();  

?>