How to implement search engine Class with PHP
Editor to share with you how to achieve PHP search engine class, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
PHP search engine class 1. Class file:
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 ("/ (. *)
/ Uis ", $_ str, $matches)
Return $matches [1] [0]
} / / end.get_title
Function get_img ($_ str=null) {
Preg_match_all ("/] *\ s*src\ sgiving =
\ s* ([\ "]?) ([^\" >\ s] *)\ 1\ s* [^ >] * > / I "
$_ str, $arr)
Print_r ($arr [2])
}
Function get_link ($_ str=null) {
Preg_match_all ("/