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://azwzsj.com/article/ijieco.html">http://azwzsj.com/article/ijieco.html</a> </div> </div> <div class="contentr fr"> <h3>其他资讯</h3> <ul> <li> <a href="/article/dicghpe.html">如何检测电脑声音故障(通过声音判断电脑故障)</a> </li><li> <a href="/article/dicghod.html">css取消div点击样式 css取消hover</a> </li><li> <a href="/article/dicghhi.html">linux一直挂载命令 linux挂载的命令</a> </li><li> <a href="/article/dicghjg.html">android图片播放 android 读取图片</a> </li><li> <a href="/article/dicghgi.html">html5替代jsp html5取代app</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="http://www.cdhuace.com/pinpai.html" title="品牌设计" target="_blank">品牌设计</a>   <a href="http://www.cdtuopan.cn/" title="成都木托盘" target="_blank">成都木托盘</a>   <a href="http://www.scdzj.cn/" title="护栏打桩机" target="_blank">护栏打桩机</a>   <a href="http://www.gzxishu.com/" title="自动门" target="_blank">自动门</a>   <a href="http://www.4006tel.net/" title="网站开发" target="_blank">网站开发</a>   <a href="http://www.ty2auto.com/" title="添翼二手车鉴定" target="_blank">添翼二手车鉴定</a>   <a href="http://mc.scmwjz.com/" title="成都雨棚定制" target="_blank">成都雨棚定制</a>   <a href="http://www.cdkjz.cn/fangan/response/" title="响应式网站建设方案" target="_blank">响应式网站建设方案</a>   <a href="http://www.kswsj.com/" title="成都网站建设" target="_blank">成都网站建设</a>   <a href="http://m.cdcxhl.cn/shop/ " title="商城网站建设公司" target="_blank">商城网站建设公司</a>    </div> </div> </div> <div class="copy container"> Copyright © 2024 All Rights Reserved. 四川阿坝州网站建设公司 版权所有 <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备2024099935号-3 </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/jiangan.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>