We have introduced you in detail about
PHP search engine class 1. Class files:
- class grabble{
- var $filename;
- var $html;
-
var $urls = array(); //url历史
- var $url ;
- var $url_1;
- function grabble(){
- set_time_limit(3600);
- }
- function set($_filename){
-
$this->filename = $_filename;
-
array_push ($this->url, $_filename);
- }//end.set;
- function set_url($_url){
- eregi('(^http://.*[^/]).*' , $_url , $array);
-
$this->url = $array[1] . "/";
- eregi('(^http://.*[^/]).*' , $_url , $array);
- //print_r($array);
-
$this->url_1 = $array[1];
- }
- function get(){
- }//end.get;
-
function get_html($_filename=null){
-
$this->filename = $_filename;
-
$this->html = @implode('', file($_filename)) ;
-
return $this->html;
- }//end.get_html;
-
function get_title($_str=null){
-
preg_match_all("/<title>(.*)</title>
/Uis", $_str, $matches);
- return $matches[1][0];
- }//end.get_title;
-
function get_img($_str=null){
-
preg_match_all("/<imgs+[^>]*s*srcs*=
s*(['"]?)([^'">s]*)1s*[^>]*>/i",
$_str, $arr);
- print_r($arr[2]);
- }
-
function get_link($_str=null){
-
preg_match_all("/<a.*href=['|"](.+)?
['|"].*>.+</a>/Uis", $_str, $arr);
- //print_r($arr);
- return $arr[1];
- }//end.get_link;
-
function get_link_name($_str=null){
-
preg_match_all("/<a.*href=['|"](.+)?
['|"].*>(.+)</a>/Uis", $_str, $arr);
- return $arr[2];
- }//end.get_link_name;
-
function link_list($_url=null, $_c=0){
- eregi('(^http://.*)/.*' , $_url , $array);
-
$_url_0 = $array[1];
-
$_html = $this->get_html($_url);
-
$_link = $this->get_link($_html);
-
$_list = $this->get_link_name($_html);
-
$s = "";
-
for($i=0;$i<count($_link);$i++){
- $s .= "
" . "<INPUT TYPE='checkbox'
NAME='link_name[]' value='" .$_link[$i]. "'
/>" . $_list[$i] . " ";
-
echo "<br/>" . "<INPUT TYPE='checkbox'
NAME='link_name[]' value='" .$_link[$i]. "'
/>" . $_list[$i] . " ";
-
echo "<a href='" . $_url_0 . "/" . $_link[$i]
. "' target='_blank'>" . $_url_0 . "/" .
$_link[$i] . "a>";
-
if($_c < 3){
- if(eregi('^[$_url_0|mailto:].*' ,$_link[$i])){
- echo "<a href='" . $_link[$i] . "'
target='_blank'>" . $_link[$i] . "a>";
-
$s .= $this->link_list( $_link[$i] , $_c+1);
- }
- elseif(!eregi('^[http://|ftp://|file:///].
*' ,$_link[$i])){ -
$s .= $this->link_list( $_url_0 . "/" . $_link[$i] , $_c+1);
- }
- }
- }
- return $s;
- }//end.link_list;
- }//end.grabble.
PHP搜索引擎类2.调用实例:
<ol class="dp-xml">
<li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>require_once("grabble.<br />class.php"); </span></li><li class="alt"><span>$</span><span class="attribute">gf</span><span> = </span><span class="attribute-value">new</span><span> grabble(); </span></li><li><span>echo $gf-</span><span class="tag">></span><span>link_list(<br>'http://10.22.65.101/'); </span></span></li>
<li class="alt">
<span class="tag">?></span><span> </span>
</li>
</ol><br>
The above is the related usage of PHP search engine class.
http://www.bkjia.com/PHPjc/445961.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445961.htmlTechArticleWe have introduced in detail the PHP search engine class 1. Class file: classgrabble{ var$filename; var$ html; var$ urls = array ();//url history var$url; var$url_1; functiongrabble(){ se...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn