php 读取google输出到本地
提供一款查询收录时常用的google正则表达式功能哦,我们是取得内容然后再正则出我们想要的内容,再在本地输出。
<?php $TheUrl="http://www.google.cn/search?q=+site:".$q."&num=20&complete=1&hl=zh-CN&lr=&newwindow=1&as_qdr=".$t."&start=".$p."&sa=N"; $TheThie=GetPage($TheUrl); } $TheBody=GetContent($TheThie,"<div id=res class=med>","<div id=bsf style"); $TheBody=iconv( "UTF-8", "gb2312//IGNORE" , $TheBody); $TheBody=str_replace("<!--z--><p><i>","<!--z--><!--<p><i>",$TheBody); $TheBody=str_replace('<br clear="all"/>','<br clear="all"/>',$TheBody); $TheBody=preg_replace('<a href="/search?num=20(.+?)amp;as_qdr=(.+?)&q=site:(.+?)&start=(.+?)&sa=N">','a href=?q=$3&t=$2&p=$4> <!--z--',$TheBody); $TheBody=str_replace("该网站可能含有恶意软件,有可能会危害您的电脑。","",$TheBody); $TheBody=str_replace("/interstitial?url=","",$TheBody); $TheBody=str_replace("- <nobr>","",$TheBody); $TheBody=str_replace("类似网页","",$TheBody); $total=GetContent($TheThie,"</b></div><p>","</b> - <b>"); $total=iconv( "UTF-8", "gb2312//IGNORE" , $total); $total=GetContent($total,"有 <b>","</b> 项"); $total=str_replace("有 <b>","",$total); $total=str_replace(",","",$total); $total=intval($total);
文章网址:http://www.phprm.com/code/b94b0c6eb42fb1d26ced1b94dcf2ee7e.html
随意转载^^但请附上教程地址。