实例讲解PHP搜索引擎类

疆括仕网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

实例讲解PHP搜索引擎类

我们为大家详细介绍了有关PHP搜索引擎类的一些使用方法,希望对大家有些帮助。下面我们先以一个范例来讲解类文件的概念。#t#

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);  </li><li>return $matches[1][0];  </li><li>}//end.get_title;  </li><li>function get_img($_str=null){  </li><li>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);  </li><li>print_r($arr[2]);  </li><li>}  </li><li>function get_link($_str=null){   </li><li>preg_match_all("/<strong><a.</strong>*href=[\'|\"](.+)?<br /> [\'|\"].*<strong>></strong>.+<strong><</strong>\/a<strong>></strong>/Uis", $_str, $arr);   </li><li>//print_r($arr);  </li><li>return $arr[1];  </li><li>}//end.get_link;  </li><li>function get_link_name($_str=null){   </li><li>preg_match_all("/<strong><a.</strong>*href=[\'|\"](.+)?<br /> [\'|\"].*<strong>></strong>(.+)<strong><</strong>\/a<strong>></strong>/Uis", $_str, $arr);  </li><li>return $arr[2];  </li><li>}//end.get_link_name;  </li><li>function link_list($_url=null, $_c=0){  </li><li>eregi('(^http://.*)/.*' , $_url , $array);  </li><li>$_url_0 = $array[1];  </li><li>$_html = $this-<strong>></strong>get_html($_url);  </li><li>$_link = $this-<strong>></strong>get_link($_html);  </li><li>$_list = $this-<strong>></strong>get_link_name($_html);  </li><li>$s = "";  </li><li>for($i=0;$i<strong><count</strong>($_link);$i++){  </li><li>$s .= "<br/>" . "<strong><INPUT</strong> TYPE='checkbox' <br /> NAME='link_name[]' value='" .$_link[$i]. "' <br /> <strong>/></strong>" . $_list[$i] . "  ";  </li><li>echo "<strong><br/></strong>" . "<strong><INPUT</strong> TYPE='checkbox' <br /> NAME='link_name[]' value='" .$_link[$i]. "' <br /> <strong>/></strong>" . $_list[$i] . "  ";  </li><li>echo "<strong><a</strong> href='" . $_url_0 . "/" . $_link[$i]<br />  . "' target='_blank'<strong>></strong>" . $_url_0 . "/" . <br /> $_link[$i] . "<strong></a></strong>";   </li><li>if($_c <strong><</strong> <strong>3</strong>){  </li><li>if(eregi('^[$_url_0|mailto:].*' ,$_link[$i])){   </li><li>echo "<strong><a</strong> href='" . $_link[$i] . "' <br /> target='_blank'<strong>></strong>" . $_link[$i] . "<strong></a></strong>";   </li><li>$s .= $this-<strong>></strong>link_list( $_link[$i] , $_c+1);  </li><li>}  </li><li>elseif(!eregi('^[http://|ftp://|file:///].<br /> *' ,$_link[$i])){  </li><li>$s .= $this-<strong>></strong>link_list( $_url_0 . "/" . $_link[$i] , $_c+1);  </li><li>}  </li><li>}  </li><li>}  </li><li>return $s;  </li><li>}//end.link_list;  </li><li>}//end.grabble. </li></ol><p><strong>PHP搜索引擎类2.调用实例:</strong></p><pre> <ol> <li>< ?php  </li> <li>require_once("grabble.<br>class.php");  </li> <li>$gf = new grabble();  </li> <li>echo $gf->link_list(<br>'http://10.22.65.101/');  </li> <li>?> </li> </ol><br></pre><p> 以上就是PHP搜索引擎类的相关使用方法。</p> <br> 网站标题:实例讲解PHP搜索引擎类 <br> 当前地址:<a href="https://tyhkzb.com/article/djospoe.html">https://tyhkzb.com/article/djospoe.html</a> </div> </div> <div class="othernews"> <h3>其他资讯</h3> <div class="othernews_list"> <ul> <li> <a href="/article/djsggsj.html">SEO技术:如何通过网页布局实现快速排名?(SEO秒排策略)</a> </li><li> <a href="/article/djsgigs.html">服务发现:CPorAP?</a> </li><li> <a href="/article/djsggeh.html">云机房建设成本?搭建小型服务器机房需要多少钱</a> </li><li> <a href="/article/djsggig.html">系统相册在那找?(windows8相册首页)</a> </li><li> <a href="/article/djsggjc.html">如何在网站上实现SSL加密</a> </li> </ul> </div> </div> </div> </div> <div class="footer"> <div class="footer_content"> <div class="footer_content_top clear"> <div class="content_top_share fl"> <div><img src="/Public/Home/img/logo.png"></div> <div class="top_share_content"> <dd>分享至:</dd> <dt class="bdsharebuttonbox clear" id="share"> <a href="#" class="bds_tsina iconfont fl" data-cmd="tsina" title="分享到新浪微博"></a> <a href="#" class="bds_sqq iconfont fl" data-cmd="sqq" title="分享到QQ好友"></a> <a href="#" class="bds_weixin iconfont fl" data-cmd="weixin" title="分享到微信"></a> <a href="#" class="bds_weixin iconfont fl" data-cmd="tieba" title="分享到贴吧"></a> </dt> <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script> </div> </div> <div class="content_top_left fl clear"> <div class="top_left_list fl"> <dd><a href="/about/">关于我们</a></dd> <dt> <a href="/about/#gsjj">公司简介</a> <a href="/about/#fzlc">发展历程</a> </dt> </div> <div class="top_left_list fl"> <dd><a href="/service/">服务项目</a></dd> <dt> <a href="/service/">高端网站建设</a> <a href="/miniprogram/">小程序开发</a> <a href="/service/app.html">APP开发</a> <a href="/service/yingxiao.html">网络营销</a> </dt> </div> <div class="top_left_list fl"> <dd><a href="/jianzhan/">建站知识</a></dd> <dt> <a href="/jianzhan/">行业新闻</a> <a href="/jianzhan/">建站学堂</a> <a href="/jianzhan/">常见问题</a> </dt> </div> <div class="top_left_list fl"> <dd><a href="/contact/">联系我们</a></dd> <dt> <a href="/contact/#lxwm">公司地址</a> <a href="/contact/#rczp">人才招聘</a> </dt> </div> </div> <div class="content_top_right addressR fr"> <div class="top_right_title addressf_title"> <a href="javascript:;" class="on">成都</a> <a href="javascript:;">大悟县</a> </div> <div class="top_right_content addressf"> <div class="right_content_li on"> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">电话:028-86922220</dt> </div> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">地址:成都市太升南路288号锦天国际A幢1002号</dt> </div> </div> <div class="right_content_li"> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">电话:028-86922220</dt> </div> <div class="right_content_list clear"> <dd class="fl iconfont"></dd> <dt class="fl">地址:湖省孝感市大悟县城关镇鄂北物流城13栋125号</dt> </div> </div> </div> </div> </div> </div> <div class="footer_content_copyright clear">版权所有:大悟县疆括仕商贸有限公司 <a href="http://beian.miit.gov.cn/" rel="nofollow" target="_blank">鄂ICP备2025139637号-7</a> </div> </div> <!--浮窗--> <div class="FloatingWindow clear"> <a href="tencent://message/?uin=1683211881&Site=&Menu=yes" class="FloatingWindow_list fr"> <div class="FloatingWindow_list_title"> <dd class="iconfont"></dd> <dt><span>在线</span>咨询</dt> </div> </a> <a href="javascript:;" class="FloatingWindow_list fr"> <div class="FloatingWindow_list_title"> <dd class="iconfont"></dd> <dt>服务热线</dt> </div> <div class="FloatingWindow_list_down fadeInRight animated">服务热线:028-86922220</div> </a> <a href="javascript:;" class="FloatingWindow_list fr STop"> <div class="FloatingWindow_list_title"> <dd class="iconfont"></dd> <dt>TOP</dt> </div> </a> </div> <script src="/Public/Home/js/jquery-1.8.3.min.js"></script> <script src="/Public/Home/js/comm.js"></script> <script src="/Public/Home/js/wow.js"></script> <script src="/Public/Home/js/common.js"></script> </body> </html> <script> $(".cont 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>