A. 用php怎样实现一个文本搜索引擎
什么叫数据库是用txt的??
搜索静态网页,可以直接用fopen,file之类函数打开文件,然后用字符串函数strstr等来查询是否含有搜索关键字,最好是用字符串的一些函数,因为eregi等函数在这个问题上的效率要低的多
B. php搜索引擎蜘蛛程序
推荐一个国外知名度颇高的搜索引擎,含有网页蜘蛛程序,以前好象有人想要这方面的资料,现在有了,大家可以研究下源码。
官方网站:
http://phpdig.toiletoine.net/
演示:
http://phpdig.toiletoine.net/sea ... te=100&option=start
中文版本和演示,我以前提供过(1.62版本的汉化),2003年11月换空间的时候没备份,没了。找下载了的人看看有没有。
下载:
这是最近(2003年12月)更新的版本的下载(1.65 En):
http://www.phpdig.net/navigation.php?action=download
演示:
http://www.phpdig.net/navigation.php?action=demo
主要功能:
类似google、网络的搜索引擎,php+mysql。
PhpDig is a http spider/search engine written in Php with a MySql database in backend.
HTTP Spidering : PhpDig follows links as it was any web browser within a web server, to build the pages list to index. Links can be in AreaMap, or frames. PhpDig supports relocations. Any syntax of HREF attribute is followed by Phpdig.
PhpDig don't go out the root site you define for the indexing. Spidering depth is choosen by user.
All html content is listed, both static and dynamic pages. PhpDig searches the Mime-Type of the document, or tests existence of an tag at the beginning of it.
支持全文搜索
Full Text indexing : PhpDig indexes all words of a document, excepting small words (less than 3 letters) an common words, those are definded in a text file.
Lone numbers are not inded, but those included in words. Underscores make part of a word.
Occurences of a word in a document is saved. Words in the title can have a more important weight in ranking results.
支持多种格式文件的索引,如pdf
File types wich can be indexed : PhpDig indexes HTML and text files by itself.
PhpDig could index PDF, MS-Word and MS-Excel files if you install external binaries on the spidering machines to this purpose.
To demonstrate the feature, you can search into Hamlet (tragedy, William Shakespeare) in MS-Word format, and L'Avare (comedy, Molière) in Pdf format.
支持robots
Other features : PhpDig Tries to read a robots.txt file at the server root. It searches meta robots tags too.
The Last-Modified header value is stored in the database to avoid rendant indexing. Also the meta revisit-after tag.
可针对特定网站进行全文索引,蜘蛛可1-9个层自动获取全部url
其中的蜘蛛程序写得十分好,有兴趣的朋友推荐研究下。
希望对你有用!
C. 求问大神php怎么简单实现搜索引擎 就是文本框输入值然后点击按钮下面出现输入的值并且变红
将搜索结果内容中的关键字替换成<span style="color:#f00;"> 关键字</span>
D. php 分词,搜索引擎,技术
你好,很高兴为你解答:
如果你仅仅是要把长句中的单词分出来,那是很简单的:
<?php
$str="GoogleTranslateforBusiness!";
$str=preg_replace("{.|,|;|:|'|"|?|!|<|>|(|)}","",$str);//移除所有标点符号
$arr=array_unique(explode("",$str));//以空格分割,并去重
var_mp($arr);
?>
以下是一段测试文本:
(asseeninCorPerl),"something"(inthiscase,output"Hi,I'maPHPscript!").<?phpand?>"PHPmode."
-,.,.,andthenthere'.
,.Don''sfeatures.Youcanjumpin,inashorttime,.
AlthoughPHP'sdevelopmentisfocusedonserver-sidescripting,youcandomuchmorewithit.Readon,andseemoreintheWhatcanPHPdo?section,.
输出结果:
Instead,of,lots,commands,to,output,HTML,as,seen,in,C,or,Perl,PHP,pages,contain,with,embedded,code,that,does,something,this,case,Hi,Im,a,script,The,is,enclosed,special,start,and,end,processing,instructions,php,,allow,you,jump,into,out,modeWhat,distinguishes,from,like,client-side,javaScript,the,executed,on,server,generating,which,then,sent,client,would,receive,results,running,but,not,know,what,underlying,was,You,can,even,configure,your,web,process,all,files,theres,really,no,way,users,tell,have,up,sleeveThe,best,things,using,are,it,extremely,simple,for,newcomer,offers,many,advanced,features,professional,programmer,Dont,be,afraid,reading,long,list,PHPs,short,time,writing,scripts,few,hoursAlthough,development,focused,server-side,scripting,do,much,more,Read,see,What,section,go,right,introctory,tutorial,if,only,interested,programming
使用sort()对其进行排序:
C,Dont,HTML,Hi,Im,Instead,JavaScript,PHP,PHPs,Perl,Read,The,What,You,a,advanced,afraid,all,allow,and,are,as,be,best,but,can,case,client,client-side,code,commands,configure,contain,development,distinguishes,do,does,embedded,enclosed,end,even,executed,extremely,features,few,files,focused,for,from,generating,go,have,hoursAlthough,if,in,instructions,interested,into,introctory,is,it,jump,know,like,list,long,lots,many,modeWhat,more,much,newcomer,no,not,of,offers,on,only,or,out,output,pages,php,process,processing,professional,programmer,programming,reading,really,receive,results,right,running,script,scripting,scripts,section,see,seen,sent,server,server-side,short,simple,sleeveThe,something,special,start,tell,that,the,then,theres,things,this,time,to,tutorial,underlying,up,users,using,was,way,web,what,which,with,would,writing,you,your
-----------------------------------
如有疑问欢迎追问!
满意请点击右上方【选为满意回答】按钮么么哒 o(∩_∩)o
E. php中如何使用sphinx搜索引擎
一. 安装、配置
1.ubuntu安装sphinx
如果没有安装aptitude ,需要先安装 aptitude
2.配置
3.执行命令分词,会在/var/lib/sphinxsearch/data/test1 目录下生成一堆索引文件
sudo indexer -c /etc/sphinxsearch/sphinx.conf test1
test1为上述配置文件的index名字
4.命令行测试搜索
sudo search -c /etc/sphinxsearch/sphinx.conf google
二.在php中使用,安装php、sphinx的依赖库
安装 aptitudeapt-get install aptitude
sudo aptitude install libsphinxclient-dev libsphinxclient-0.0.1 -y
2.安装php sphinx的扩展
安装 pecl
sudo apt-get install php-pear php5-dev
在安装sphinx
sudo pecl install sphinx
3.在配置文件php.ini中添加sphinx的扩展,
我的php.ini文件为
sudo vim /etc/php5/fpm/php.ini
获取自己的php.ini文件位置使用
php5-fpm -i|grep ini
添加:
extension=sphinx.so
4.重启php5-fpm,查看php是否加载sphinx模块
sudo /etc/init.d/php5-fpm restart
5.将search程序运行在后台
sudo searchd -c /etc/sphinxsearch/sphinx.conf
默认监听配置文件中的端口:9312
6.在thinkphp中调用搜索
搜索完毕,返回结果(默认返回20条,修改返回条数用添加$s->SetLimits(0, 1000, 1000);),搜索速度相当快,索引80w条数据的title和description两个字段耗时不到10s,该搜索引擎支持增量索引,多种模式的搜索,网上的资料也非常多
F. PHP全文索引、搜索引擎
http://wenku..com/view/40b10e63ddccda38376baf90.html这是一个网络文库的资料,如果你又账号,最好下载下来看,应该不错
G. 开源 中文php搜索引擎有哪些
某目前接触到的只有lucene和coreseek了
lucene更多是用在java方面的,但是也可以和php结合起来用
coreseek和php结合使用比较好,官方文档说的很详细
君且自学自勉哇。
H. php可以做搜索引擎吗
大部分知名网站后台都是使用PHP处理的,那是因为PHP的LAMP深得人心.
就像PHPCHINA的FANS们年度采访各大网站技术总监说的那样,使用LAMP是因为不用花钱,速度还可以,但是对于重要的数据使用ORACLE,那是因为,ORACLE花了大价钱,就会有大的服务,LAMP都是免费的!
I. 如何用PHP制作搜索引擎
这样看你做什么样的搜索,如果要做全站搜索的话,只用数据库搜索做起来会比较困难,会遇到要检索的数据存在不同的表中,甚至不同的库中,如果是全站搜索的话,建议用sphinx或者lucener,如果只是某个表内容搜索的话,sql:select * from 表名 where 列名 like '%值%' ;然后循环 mysql_fetch_array() 或 mysql_fetch_assoc() 或 mysql_fetch_object() 或 mysql_fetch_row()都取一行记录,把记录循环出来就可以了。
J. php做搜索引擎,实现随机输入字符串,能找出包含该字符串的所有文件,并列出文件的路径
能实现,你要熟悉PHP的目录函数
chdir -- 改变目录
chroot -- 改变根目录
dir -- directory 类
closedir -- 关闭目录句柄
getcwd -- 取得当前工作目录
opendir -- 打开目录句柄
readdir -- 从目录句柄中读取条目
rewinddir -- 倒回目录句柄
scandir -- 列出指定路径中的文件和目录
还有就是读文件的函数。
你可以遍历目录,并读取目录下的每个文件,并用 strpos函数匹配输入的字符串是否存在,最终得到结果