The example explains the PHP search engine class. We have introduced in detail the PHP search engine class 1. class File: classgrabble {var $ filename; var $ html; var $ urlsarray (); url history var $ url; var $ url_1; functiongrabble () {se
PHP search engine class 1. class files:
- Class grabble {
- Var $ filename;
- Var $ html;
- Var $ urls = array (); // url history
- 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 ("/</Strong> (.*)</Title>
/Uis ", $ _ str, $ matches );
- Return $ matches [1] [0];
- } // End. get_title;
- Function get_img ($ _ str = null ){
- Preg_match_all ("/S + [^>] * S * srcs * =
S * (['"]?) ([^ '">S] *) \ 1 s * [^>] *>/I ",
$ _ Str, $ arr ); - Print_r ($ arr [2]);
- }
- Function get_link ($ _ str = null ){
- Preg_match_all ("/ * Href = ['| "] (. + )?
['| "]. * >. + </ >/Uis ", $ _ str, $ arr ); - // Print_r ($ arr );
- Return $ arr [1];
- } // End. get_link;
- Function get_link_name ($ _ str = null ){
- Preg_match_all ("/ * Href = ['| "] (. + )?
['| "]. * >(. +) </ >/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 ($ _ Link); $ I ++ ){
- $ S. ="
"." TYPE = 'checkbox'
NAME = 'link _ name [] 'value = '". $ _ link [$ I]."'
/>". $ _ List [$ I]." "; - Echo"
"." TYPE = 'checkbox'
NAME = 'link _ name [] 'value = '". $ _ link [$ I]."'
/>". $ _ List [$ I]." "; - Echo" Href = '". $ _ url_0."/". $ _ link [$ I]
. "'Target = '_ blank' >". $ _ Url_0 ."/".
$ _ Link [$ I]." "; - If ($ _ c< 3){
- If (eregi ('^ [$ _ url_0 | mailto:]. *', $ _ link [$ I]) {
- Echo" Href = '". $ _ link [$ I]."'
Target = '_ blank' >". $ _ Link [$ I]." "; - $ 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 search engine type 2. call an instance:
- < ?php
- require_once("grabble.
class.php");
- $gf = new grabble();
- echo $gf->link_list(
'http://10.22.65.101/');
- ?>
The above describes how to use the PHP search engine class.
Sort PHP search engine class 1. class File: classgrabble {var $ filename; var $ html; var $ urls = array (); // url history var $ url; var $ url_1; functiongrabble () {se...