PHP怎么实现搜索引擎类

小编给大家分享一下PHP怎么实现搜索引擎类,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

成都创新互联公司专业为企业提供富川网站建设、富川做网站、富川网站设计、富川网站制作等企业网站建设、网页设计与制作、富川企业网站模板建站服务,十年富川做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

PHP搜索引擎类1.类文件:

  1. class grabble{  

  2. var $filename;  

  3. var $html;  

  4. var $urls = array(); //url历史  

  5. var $url ;  

  6. var $url_1;  

  7. function grabble(){  

  8. set_time_limit(3600);   

  9. }  

  10. function set($_filename){  

  11. $this->filename = $_filename;  

  12. array_push ($this->url, $_filename);   

  13. }//end.set;  

  14. function set_url($_url){  

  15. eregi('(^http://.*[^/]).*' , $_url , $array);  

  16. $this->url = $array[1] . "/";   

  17. eregi('(^http://.*[^/]).*' , $_url , $array);  

  18. //print_r($array);  

  19. $this->url_1 = $array[1];  

  20. }  

  21. function get(){  

  22. }//end.get;  

  23. function get_html($_filename=null){  

  24. $this->filename = $_filename;  

  25. $this->html = @implode('', file($_filename)) ;  

  26. return $this->html;  

  27. }//end.get_html;  

  28. function get_title($_str=null){  

  29. preg_match_all("/</strong>(.*)<strong><</strong>\/title<strong>><br/></strong>/Uis", $_str, $matches);  </p></li><li><p>return $matches[1][0];  </p></li><li><p>}//end.get_title;  </p></li><li><p>function get_img($_str=null){  </p></li><li><p>preg_match_all("/<strong><img</strong>\s+[^<strong>></strong>]*\s*src\s*=<br/>\s*([\'\"]?)([^\'\"<strong>></strong>\s]*)\\1\s*[^<strong>></strong>]*<strong>></strong>/i", <br/>$_str, $arr);  </p></li><li><p>print_r($arr[2]);  </p></li><li><p>}  </p></li><li><p>function get_link($_str=null){   </p></li><li><p>preg_match_all("/<strong><a.</strong>*href=[\'|\"](.+)?<br/>[\'|\"].*<strong>></strong>.+<strong><</strong>\/a<strong>></strong>/Uis", $_str, $arr);   </p></li><li><p>//print_r($arr);  </p></li><li><p>return $arr[1];  </p></li><li><p>}//end.get_link;  </p></li><li><p>function get_link_name($_str=null){   </p></li><li><p>preg_match_all("/<strong><a.</strong>*href=[\'|\"](.+)?<br/>[\'|\"].*<strong>></strong>(.+)<strong><</strong>\/a<strong>></strong>/Uis", $_str, $arr);  </p></li><li><p>return $arr[2];  </p></li><li><p>}//end.get_link_name;  </p></li><li><p>function link_list($_url=null, $_c=0){  </p></li><li><p>eregi('(^http://.*)/.*' , $_url , $array);  </p></li><li><p>$_url_0 = $array[1];  </p></li><li><p>$_html = $this-<strong>></strong>get_html($_url);  </p></li><li><p>$_link = $this-<strong>></strong>get_link($_html);  </p></li><li><p>$_list = $this-<strong>></strong>get_link_name($_html);  </p></li><li><p>$s = "";  </p></li><li><p>for($i=0;$i<strong><count</strong>($_link);$i++){  </p></li><li><p>$s .= "<br/>" . "<strong><INPUT</strong> TYPE='checkbox' <br/>NAME='link_name[]' value='" .$_link[$i]. "' <br/><strong>/></strong>" . $_list[$i] . "  ";  </p></li><li><p>echo "<strong><br/></strong>" . "<strong><INPUT</strong> TYPE='checkbox' <br/>NAME='link_name[]' value='" .$_link[$i]. "' <br/><strong>/></strong>" . $_list[$i] . "  ";  </p></li><li><p>echo "<strong><a</strong> href='" . $_url_0 . "/" . $_link[$i]<br/> . "' target='_blank'<strong>></strong>" . $_url_0 . "/" . <br/>$_link[$i] . "<strong></a></strong>";   </p></li><li><p>if($_c <strong><</strong> <strong>3</strong>){  </p></li><li><p>if(eregi('^[$_url_0|mailto:].*' ,$_link[$i])){   </p></li><li><p>echo "<strong><a</strong> href='" . $_link[$i] . "' <br/>target='_blank'<strong>></strong>" . $_link[$i] . "<strong></a></strong>";   </p></li><li><p>$s .= $this-<strong>></strong>link_list( $_link[$i] , $_c+1);  </p></li><li><p>}  </p></li><li><p>elseif(!eregi('^[http://|ftp://|file:///].<br/>*' ,$_link[$i])){  </p></li><li><p>$s .= $this-<strong>></strong>link_list( $_url_0 . "/" . $_link[$i] , $_c+1);  </p></li><li><p>}  </p></li><li><p>}  </p></li><li><p>}  </p></li><li><p>return $s;  </p></li><li><p>}//end.link_list;  </p></li><li><p>}//end.grabble. </p></li></ol><p><strong>PHP搜索引擎类2.调用实例:</strong></p><pre><ol><li><p>< ?php  </p></li><li><p>require_once("grabble.<br/>class.php");  </p></li><li><p>$gf = new grabble();  </p></li><li><p>echo $gf->link_list(<br/>'http://10.22.65.101/');  </p></li><li><p>?> </p></li></ol><br/></pre><p>以上是“PHP怎么实现搜索引擎类”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!</p> <br> 网站栏目:PHP怎么实现搜索引擎类 <br> 分享地址:<a href="http://ybzwz.com/article/ijieco.html">http://ybzwz.com/article/ijieco.html</a> </div> </div> <div class="contentr fr"> <h3>其他资讯</h3> <ul> <li> <a href="/article/pegdjo.html">MySQL的binlog怎么使用</a> </li><li> <a href="/article/pegdji.html">angularJs中datatable怎么实现</a> </li><li> <a href="/article/pegded.html">Notepad++自动更新如何关闭</a> </li><li> <a href="/article/pegddg.html">HTML5中怎么实现video事件</a> </li><li> <a href="/article/pegdid.html">Centos7搭建FTP服务器</a> </li> </ul> </div> </div> </div> <!--底部--> <footer> <div class="foot"> <div class="container"> <h1>小谭建站您身边的网站建设服务商</h1> <div class="foot1"> <ul> <li> <dl><i class="iconfont"></i><b>地址ADDRESS</b></dl> <p>四川-成都青羊区太升南路288号<br> 锦天国际A座10楼 </p> </li> <li> <dl><i class="iconfont"></i><b>电话/TEL</b></dl> <p><a href="tel:02886922220" target="_blank">028 86922220</a> (工作日)<br> <a href="tel:18980820575" target="_blank">1898082 0575</a> ( 7x24 ) </p> </li> <li> <dl><i class="iconfont"></i><b>QQ咨询</b></dl> <p> 244261566 (售前)<br> 631063699 (售后) </p> </li> <li> <dl><i class="iconfont"></i><b>邮箱/E: mail</b></dl> <p> service@cdcxhl.com (业务)<br> hr@cdcxhl.com (求职) </p> </li> </ul> </div> <div class="link"> 友情链接: <a href="https://www.cdcxhl.com/tuoguan.html" title="成都服务器托管" target="_blank">成都服务器托管</a>   <a href="http://www.pzhzwz.com/" title="攀枝花网站建设" target="_blank">攀枝花网站建设</a>   <a href="http://www.cdhuace.com/biaoshi.html" title="成都导视系统设计" target="_blank">成都导视系统设计</a>   <a href="https://www.cdcxhl.cn/ " title="香港主机" target="_blank">香港主机</a>   <a href="http://www.ruijiemsc.com/" title="四川瑞杰" target="_blank">四川瑞杰</a>   <a href="https://www.xwcx.net/zuyong.html" title="服务器租用" target="_blank">服务器租用</a>   <a href="https://www.cdxwcx.com/jifang/ershu.html" title="成都二枢机房" target="_blank">成都二枢机房</a>   <a href="http://www.kswcd.com/solution/" title="网站建设方案" target="_blank">网站建设方案</a>   <a href="http://www.cdweb.net/solve/" title="网站建设方案" target="_blank">网站建设方案</a>   <a href="http://www.shengjin119.com/" title="胜锦安防科技" target="_blank">胜锦安防科技</a>    </div> </div> </div> <div class="copy container"> Copyright © 2017-2022 All Rights Reserved. 青羊区小谭信息技术咨询服务工作室 版权所有 <a href="http://www.beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备2021004003号-22</a> [原创设计,独立版权。未经许可.不得拷贝或镜像]<br> <a href="http://www.kswsj.cn/" target="_blank">网站营销推广</a> | <a href="https://www.cdcxhl.com/pinpai.html" target="_blank">品牌网站设计</a> | <a href="http://www.cdweb.net/" target="_blank">自适应网站建设</a> | <a href="http://cdkjz.cn/wangzhan/pinpai/" target="_blank">品牌网站建设</a> | <a href="http://chengdu.cdxwcx.cn/" target="_blank">成都网站制作</a> | <a href="https://www.cdcxhl.com/cloud/" target="_blank">云服务器</a> | <a href="https://www.cdcxhl.com/weihu/abazhou.html" target="_blank">宜宾网站维护</a> | (宜宾网站建设QQ : 631063699 )</div> </footer> <!--在线咨询--> <div class="fot"> <ul> <li> <a href="mqqwpa://im/chat?chat_type=wpa&uin=532337155&version=1&src_type=web&web_src=oicqzone.com" target="_blank"> <img src="/Public/Home/img/fot1.png" alt="建站咨询"> <p>在线咨询</p> </a> </li> <li> <a href="tel:18980820575" target="_blank"> <img src="/Public/Home/img/fot2.png" alt="建站电话"> <p>拨打电话</p> </a> </li> </ul> </div> </body> </html> <script> $(".con img").each(function(){ var src = $(this).attr("src"); //获取图片地址 var str=new RegExp("http"); var result=str.test(src); if(result==false){ var url = "https://www.cdcxhl.com"+src; //绝对路径 $(this).attr("src",url); } }); window.onload=function(){ document.oncontextmenu=function(){ return false; } } </script>