实例讲解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> <p> 当前名称:<a href="http://www.csdahua.cn/qtweb/news32/459932.html">实例讲解PHP搜索引擎类</a> <br> 本文链接:<a href="http://www.csdahua.cn/qtweb/news32/459932.html">http://www.csdahua.cn/qtweb/news32/459932.html</a> </p> <p> 网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等 </p> <p class="adpic"> <a href="https://www.cdcxhl.com/service/ad.html" target="_blank" class="ad">广告</a> <a href="" target="_blank" class="adimg"><img src=""></a> </p> <p class="copy"> 声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: <a href="http://www.csdahua.cn/" target="_blank">快上网</a> </p> </div> <div class="newsmorelb"> <p>成都快上网为您推荐相关内容</p> <ul> <li> <a href="/qtweb/news31/459931.html">windowscmd文件权限命令?(cmd设置文件权限)</a> </li><li> <a href="/qtweb/news30/459930.html">混合VS多云:Kafka架构中的五个主要比较</a> </li><li> <a href="/qtweb/news29/459929.html">微服务的灾难:折磨人的环境!</a> </li><li> <a href="/qtweb/news28/459928.html">百度联盟主题推广优质模板推荐</a> </li><li> <a href="/qtweb/news27/459927.html">Scala程序中如何实现多态和动态绑定</a> </li><li> <a href="/qtweb/news26/459926.html">阿里云正版图片</a> </li><li> <a href="/qtweb/news25/459925.html">python监控曲线_开始监控Python应用</a> </li><li> <a href="/qtweb/news24/459924.html">云端游戏服务器配置错误的解决方案</a> </li><li> <a href="/qtweb/news23/459923.html">使用香港服务器时要考虑哪几个方面事项</a> </li> </ul> </div> </div> <div class="col-lg-3 noneb"> <div class="bkright" style="margin-top: 0"> <p><a href="https://www.cdcxhl.com/news/jianshe/">网站建设知识</a></p> <ul> <li> <a class="text_overflow" href="/qtweb/news3/384853.html">云服务器除了搭建网站还可以干什么呢</a> </li><li> <a class="text_overflow" href="/qtweb/news21/510171.html">ug编程都有什么加工方式呢</a> </li><li> <a class="text_overflow" href="/qtweb/news32/16682.html">风扇怎么画?(风扇怎么画简笔画)</a> </li><li> <a class="text_overflow" href="/qtweb/news49/533249.html">电脑存储池有什么用?windows存储池</a> </li><li> <a class="text_overflow" href="/qtweb/news24/413924.html">真正的智能家居攻击来了DDoS令公寓住户挨冻</a> </li><li> <a class="text_overflow" href="/qtweb/news23/183723.html">windows10怎么下载和平精英?(我电脑win10系统?)</a> </li><li> <a class="text_overflow" href="/qtweb/news30/91830.html">Linux蓝牙程序的使用方法及注意事项(linux蓝牙程序)</a> </li><li> <a class="text_overflow" href="/qtweb/news3/68703.html">关于UML视图和图内容全面解析</a> </li><li> <a class="text_overflow" href="/qtweb/news7/250357.html">如何将app部署在阿里云服务器上?云服务器上可以安装软件吗</a> </li><li> <a class="text_overflow" href="/qtweb/news31/299381.html">HTML5书籍推荐</a> </li><li> <a class="text_overflow" href="/qtweb/news32/122282.html">机房服务器有辐射吗?(服务器机柜:辐射真相解析)</a> </li><li> <a class="text_overflow" href="/qtweb/news34/396884.html">ORA-01722:invalidnumberORACLE报错故障修复远程处理</a> </li><li> <a class="text_overflow" href="/qtweb/news35/94935.html">玩转Linux,更爱你的电视盒(linux电视盒)</a> </li><li> <a class="text_overflow" href="/qtweb/news14/296164.html">实现MSSQL数据库还原的简易指南(mssql数据库怎么还原)</a> </li><li> <a class="text_overflow" href="/qtweb/news7/23007.html">阿里云的虚拟主机怎么用?(阿里云购买虚拟主机怎么用不了)</a> </li> </ul> </div> <div class="bkright tag"> <p><a href="https://www.cdcxhl.com/hangye/" target="_blank">同城分类信息</a></p> <ul> <li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/weilanhulan/" target="_blank">围栏护栏</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/bangongkongjian/" target="_blank">办公空间设计</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/zbljbc/" target="_blank">自拌料搅拌车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/pe/" target="_blank">PE包装袋</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/yupeng/" target="_blank">雨棚定制</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/hntjbg/" target="_blank">混凝土搅拌罐</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/mutuopan/" target="_blank">木托盘</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/bengche/" target="_blank">混凝土泵车</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/shayanfudiao/" target="_blank">砂岩浮雕</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/chayisj/" target="_blank">茶艺设计</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/shiliangting/" target="_blank">石凉亭</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/fwqzy/" target="_blank">服务器租用</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/vr/" target="_blank">VR全景</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/shipaifang/" target="_blank">石牌坊</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/huisuosj/" target="_blank">会所设计</a> </li><li class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> <a href="https://www.cdcxhl.com/hangye/baiwuyu/" target="_blank">白乌鱼</a> </li> </ul> </div> </div> </div> <div class="carousel-inner linkbg" style="background: #fff"> <div class="container"> <a href="http://www.cdhuace.com/led.html" target="_blank">LED显示屏厂家</a>    <a href="https://www.cdcxhl.com/ruanwen/yingxiao" target="_blank">软文营销</a>    <a href="http://www.ty2auto.com/" target="_blank">添翼二手车鉴定</a>    <a href="https://www.cdcxhl.cn/ " target="_blank">免备案空间腾讯云</a>    <a href="http://m.cdcxhl.cn/mobile/" target="_blank">网站建设公司</a>    <a href="http://www.wjzwz.com/" target="_blank">温江网站制作</a>    <a href="http://www.cxjianzhan.cn/fwxm/pinpai.html" target="_blank">成都品牌网站设计</a>    <a href="http://www.kswcd.com/service/" target="_blank">品牌网站定制</a>    <a href="http://www.dcwzsj.com/" target="_blank">德昌麦琪建站</a>    <a href="http://www.scltwjx.com/ " target="_blank">公路打桩机</a>    <a href="https://www.cdcxhl.cn/ " target="_blank">香港虚拟主机空间</a>    <a href="http://m.cdxwcx.com/xibuxinxi.html" target="_blank">西部信息服务器托管</a>    <a href="http://chengdu.cdcxhl.cn/ " target="_blank">成都网站建设</a>    <a href="http://seo.cdkjz.cn/seo/" target="_blank">关键词优化</a>    <a href="http://www.cdxwcx.cn/tuoguan/xiyun.html" target="_blank">成都移动服务器托管</a>    <a href="https://www.cdxwcx.com/wangzhan/applet.html" target="_blank">微信小程序开发</a>    <a href="https://www.cdcxhl.com/xiaochengx.html" target="_blank">成都小程序开发</a>    <a href="http://www.yunshangf.com/" target="_blank">成都发电车出租</a>    <a href="http://www.76089.cn/" target="_blank">成都翻译公司</a>    <a href="https://www.cdxwcx.com/jifang/zongshu.html" target="_blank">成都棕树电信机房</a>     </div> </div> <footer> <div class="carousel-inner footjz"> <div class="container"> <i class="icon iconfont zbw"></i> 高品质定制 <i class="icon iconfont"></i> 跨终端自动兼容 <i class="icon iconfont"></i> 节约开发成本 <i class="icon iconfont"></i> 开发周期短 <i class="icon iconfont"></i> 一体化服务 <button type="button" class="btn btn-default btn-lg" onClick="window.location.href='tencent://message/?uin=631063699&Site=&Menu=yes'"> 立即开始2800定制网站建设</button> <button type="button" class="btn btn-default btn-xs" onClick="window.location.href='tencent://message/?uin=631063699&Site=&Menu=yes'"> 2800定制网站建设</button> </div> </div> <div class="carousel-inner bqsy"> <div class="container"> <div class="lxfs"> <h4 class="yutelnone">028-86922220 13518219792</h4> <h4 class="yutelblock"><a href="tel:02886922220">028-86922220</a> <a href="tel:13518219792">13518219792</a></h4> <a class="btn btn-default" href="tencent://message/?uin=532337155&Site=&Menu=yes" role="button">网站建设<span>QQ</span>:532337155</a> <a class="btn btn-default" href="tencent://message/?uin=631063699&Site=&Menu=yes" role="button">营销推广<span>QQ</span>:631063699</a> <a class="btn btn1 btn-default" href="mqqwpa://im/chat?chat_type=wpa&uin=532337155&version=1&src_type=web&web_src=oicqzone.com" role="button">网站制作<span>QQ</span>:532337155</a> <a class="btn btn1 btn-default" href="mqqwpa://im/chat?chat_type=wpa&uin=631063699&version=1&src_type=web&web_src=oicqzone.com" role="button">营销推广<span>QQ</span>:631063699</a> <a class="btn btn-default nonea" href="tencent://message/?uin=1683211881&Site=&Menu=yes" role="button">售后QQ:1683211881</a> <div class="dz">成都快上网专注: <a href="http://www.csdahua.cn/" target="_blank">网站优化</a> <a href="http://www.csdahua.cn/" target="_blank">网络推广</a> <a href="http://www.csdahua.cn/" target="_blank">网站建设</a> <address>地址:成都太升南路288号锦天国际A幢10楼</address> </div> </div> <div class="bzdh dz"><img src="https://www.cdcxhl.com/imges/bottom_logo.png" alt="创新互联"> <p><a href="https://www.cdcxhl.com/menu.html" target="_blank">成都创新互联科技有限公司</a><br> Tel:028-86922220(7x24h)</p></div> </div> </div> </footer> </body> </html> <script> $.getJSON ("../../qtwebpic.txt", function (data) { var jsonContent = { "featured":data } var random = jsonContent.featured[Math.floor(Math.random() * jsonContent.featured.length)]; $(".adpic .adimg").attr("href",random.link) $(".adpic img").attr("src",random.pic); }) </script>