实例讲解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.kswsj.com/qtweb/news32/459932.html">实例讲解PHP搜索引擎类</a> <br> 网页链接:<a href="http://www.kswsj.com/qtweb/news32/459932.html">http://www.kswsj.com/qtweb/news32/459932.html</a> </p> <p> 网站建设、网络推广公司-成都快上网,一家网站设计、网站制作公司;服务项目有等 </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.kswsj.com/" 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/wxxcx/">微信小程序知识</a></p> <ul> <li> <a class="text_overflow" href="/qtweb/news5/71355.html">创新互联GO教程:Go语言类型分支(switch判断空接口中变量的类型)</a> </li><li> <a class="text_overflow" href="/qtweb/news3/74603.html">海外电商首选国外服务器</a> </li><li> <a class="text_overflow" href="/qtweb/news9/323809.html">免费测试拨号vps的方法是什么</a> </li><li> <a class="text_overflow" href="/qtweb/news29/366779.html">MT6620Linux驱动程序简介(mt6620linux)</a> </li><li> <a class="text_overflow" href="/qtweb/news45/106395.html">探索Mongodb官网,深入了解数据库技术(数据库mongodb官网)</a> </li><li> <a class="text_overflow" href="/qtweb/news22/251522.html">差分功耗分析攻击如何破解密钥</a> </li><li> <a class="text_overflow" href="/qtweb/news39/350839.html">学好并发编程,关键是要理解这三个核心问题!</a> </li><li> <a class="text_overflow" href="/qtweb/news24/49824.html">win系统下nodejs环境安装配置?windowsnodejs下载</a> </li><li> <a class="text_overflow" href="/qtweb/news10/15660.html">互联网创业的准备:框架</a> </li><li> <a class="text_overflow" href="/qtweb/news2/419452.html">小程序怎么开店,如何微信小程序开店(如何在微信小程序里开店)</a> </li><li> <a class="text_overflow" href="/qtweb/news7/240507.html">python取随机整数的函数</a> </li><li> <a class="text_overflow" href="/qtweb/news36/316786.html">软件测试培训对学历有要求吗</a> </li><li> <a class="text_overflow" href="/qtweb/news29/511729.html">Redis测试有什么用(redis测试什么用)</a> </li><li> <a class="text_overflow" href="/qtweb/news15/253465.html">黑客创建恶意Dota2游戏模式,秘密部署后门</a> </li><li> <a class="text_overflow" href="/qtweb/news30/153680.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/qzgqb/" 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/led/" target="_blank">LED显示屏</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/zhixiang/" 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/putaojia/" 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/renzaowu/" 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/ggzz/" 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/loutihulan/" 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/blgzd/" 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/zzdb/" 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/gaokongche/" 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/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/fwqtg/" 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/suliaodai/" target="_blank">塑料袋</a> </li> </ul> </div> </div> </div> <div class="carousel-inner linkbg" style="background: #fff"> <div class="container"> <a href="http://m.xwcx.net/" target="_blank">响应式网站</a>    <a href="http://www.cqfuwuqi.com/" target="_blank">重庆托管服务器</a>    <a href="https://www.cdcxhl.com/sosuo.html" target="_blank">搜索引擎优化</a>    <a href="http://www.cdweb.net/solve/" target="_blank">网站建设方案</a>    <a href="http://www.myzitong.cn/" target="_blank">绵阳梓潼网站建设</a>    <a href="http://www.scmintian.com/" target="_blank">四川珉田机房</a>    <a href="http://www.cdxswst.com/" target="_blank">成都康明斯发电机</a>    <a href="http://www.cqhuaxiang.cn/" target="_blank">重庆花箱</a>    <a href="http://www.xnruijie.cn/" target="_blank">赛亚人环保</a>    <a href="http://www.cdkjz.cn/wangzhan/qiye/" target="_blank">成都企业网站建设</a>    <a href="https://www.cdcxhl.com/koubei.html" target="_blank">成都口碑营销公司</a>    <a href="http://www.gytzsp.com/" target="_blank">天泽尚品装饰</a>    <a href="http://www.hzlinhua.com/" target="_blank">成都茶叶销售</a>    <a href="http://mc.scmwjz.com/" target="_blank">成都雨棚定制</a>    <a href="http://www.scghjhjc.cn/" target="_blank">广汉锦华</a>    <a href="http://www.cxjianzhan.com/seo/" target="_blank">seo关键词优化</a>    <a href="http://www.cdhuace.com/huace.html" target="_blank">成都画册设计公司</a>    <a href="https://www.cdxwcx.com/tuiguang/" target="_blank">成都SEO优化</a>    <a href="https://www.cdcxhl.com/security/" target="_blank">等级保护测评</a>    <a href="https://www.cdcxhl.com/" 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> 600元建站 <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'"> 立即开始600元网站建设</button> <button type="button" class="btn btn-default btn-xs" onClick="window.location.href='tencent://message/?uin=631063699&Site=&Menu=yes'"> 600元企业网站建设</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.kswsj.com/" target="_blank">成都网站制作</a> <a href="http://www.kswsj.com/" target="_blank">网站设计</a> <a href="http://www.kswsj.com/" 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>