RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
实例讲解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="http://www.jxjierui.cn/article/djospoe.html">http://www.jxjierui.cn/article/djospoe.html</a> </div> <div class="hot_new"> <div class="page_title clearfix"> <h3>其他资讯</h3> </div> <div class="news_list clearfix"> <ul> <li> <a href="/article/dpophch.html">利用DKIM来做基于电子邮件网络钓鱼</a> </li><li> <a href="/article/dpohoog.html">浮动float方式有哪些「float浮动的用法」</a> </li><li> <a href="/article/dpophic.html">windows10启动不起来?(windows10怎么启动不了)</a> </li><li> <a href="/article/dpophpo.html">什么是独立IP空间?为什么要用独立IP空间?(使用独立IP空间建站的好处有哪些)</a> </li><li> <a href="/article/dpophpg.html">互联网怎么做品牌维护</a> </li> </ul> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <!-- 底部信息 --> <div class="footer wow fadeInUp"> <div class="rowFluid"> <div class="span12"> <div class="container"> <div class="footer_content"> <div class="span4 col-xm-12"> <div class="footer_list"> <div class="span6"> <div class="bottom_logo"><img src="/Public/Home/images/ewm.jpg" alt="微信服务号二维码" /></div> </div> <div class="span6 col-xm-12"> <div class="quick_navigation"> <div class="quick_navigation_title">快速导航</div> <ul> <li><a href="http://www.scysgg.com/" title="营山广告设计" target="_blank">营山广告设计</a></li><li><a href="http://www.slcr8.cn/" title="无纺布包装袋" target="_blank">无纺布包装袋</a></li><li><a href="https://www.cdcxhl.com/cloud/" title="云服务器" target="_blank">云服务器</a></li><li><a href="http://www.cdmuye.cn/" title="乐尚佳花箱" target="_blank">乐尚佳花箱</a></li><li><a href="https://www.cdxwcx.com/jifang/yaan.html" title="雅安服务器托管" target="_blank">雅安服务器托管</a></li><li><a href="http://www.pingmiansj.com/" title="名片印刷" target="_blank">名片印刷</a></li><li><a href="http://www.ghjhjc.com.cn/" title="广汉锦华" target="_blank">广汉锦华</a></li> </ul> </div> </div> </div> </div> <div class="span4 col-xm-6 col-xs-12"> <div class="footer_list"> <div class="footer_link"> <div class="footer_link_title">友情链接</div> <ul id="frientLinks"> <a href="https://www.cdcxhl.com/" title="网站制作" target="_blank">网站制作</a> <a href="https://www.cdcxhl.com/" title="网站建设" target="_blank">网站建设</a> <a href="https://www.cdxwcx.com/tuiguang/" title="成都网络推广" target="_blank">网络推广</a> <a href="http://seo.cdkjz.cn/" title="成都网站推广" target="_blank">网站推广</a> <a href="https://www.cdcxhl.com/xiaochengx.html" title="成都微信小程序开发" target="_blank">小程序开发</a> <a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a> </ul> <div class="footer_link_title">网站建设</div> <ul id="frientLinks"> <li><a href="/">内江浩晨众云建站</a></li> <li><a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a></li> </ul> </div> </div> </div> <div class="span4 col-xm-6 col-xs-12"> <div class="footer_list"> <div class="footer_cotact"> <div class="footer_cotact_title">联系方式</div> <ul> <li><span class="footer_cotact_type">企业:</span><span class="footer_cotact_content">青羊区浩晨众云设计工作室(个体工商户)</span></li> <li><span class="footer_cotact_type">地址:</span><span class="footer_cotact_content">成都市青羊区太升南路288号</span></li> <li><span class="footer_cotact_type">电话:</span><span class="footer_cotact_content"><a href="tel:18980820575" class="call">18980820575</a></span></li> <li><span class="footer_cotact_type">网址:</span><span class="footer_cotact_content"><a href="/" title="内江网站建设">www.jxjierui.cn</a></span></li> </ul> </div> </div> </div> </div> </div> <div class="copyright"> <p>公司名称:青羊区浩晨众云设计工作室(个体工商户) 联系电话:18980820575</p> <p><a href="http://beian.miit.gov.cn" target="_blank" rel="nofollow">网站备案号:蜀ICP备2025119795号-2</a></p> <p>内江浩晨众云建站 内江网站建设 内江网站设计 内江网站制作 <a href="http://www.cdxwcx.cn/" target="_blank">成都做网站</a></p> </div> </div> </div> </div> </body> </html> <script> $(".technical_support_box_z_info_box 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>