《制作一个个人搜索引擎(源码)(make a personal search engine (source code))》由会员分享,可在线阅读,更多相关《制作一个个人搜索引擎(源码)(make a personal search engine (source code))(16页珍藏版)》请在金锄头文库上搜索。
1、制作一个个人搜索引擎(源码)(Make a personal search engine (source code))Source: Anonymous (127) 2005-3-13 small font: switch to traditional ChineseI want to collect or share to: %Response.Buffer=TrueOneFile, Search, Engine (ofSearch, v1.0)Copyright? 000, Sixto, Luis, Santos, All, Rights, ReservedNote:This, progr
2、am, is, freeware., This, program, is, NOT, in, the, Public, Domain.You, can, freely, use, this, program, in, your, own, site.You, cannot, re-distribute, the, code, by, any, means,without, the, express, written, authorization, by, the, author.Use, this, program, at, your, own, risk.Globals -Const Val
3、idFiles = htmltxtConst RootFld = Dim MatchedDim RegexDim GetTitleDim FSDim rfLenDim RootFolderDim DocCountDim DocMatchCountDim MatchedCount-Procedure:, SearchFiles ()-Public Sub SearchFiles (FolderPath)Dim fsFolderDim fsFolder2Dim fsFileDim fsTextDim FileTextDim FileTitleDim FileTitleMatchDim MatchC
4、ountDim OutputLineGet, the, starting, folderSet fsFolder = fs.GetFolder (FolderPath)Iterate, thru, every, file, in, the, folderFor, Each, fsFile, In, fsFolder.FilesCompare, the, current, file, extension, with, the, list, of, valid, target, filesIf, InStr (1, ValidFiles, Right (fsFile.Name, 3), vBTex
5、tCompare) 0 ThenDocCount = DocCount + 1Open, the, file, to, read, its, contentSet fsText = fsFile.OpenAsTextStreamFileText = fsText.ReadAllApply, the, regex, search, and, get, the, count, of, matches, foundMatchCount = Regex.Execute (FileText).CountMatchedCount = MatchedCount + MatchCountIf MatchCou
6、nt 0 ThenDocMatchCount = DocMatchCount + 1Apply, another, regex, to, get, the, HTML, documents, titleSet FileTitleMatch = GetTitle.Execute (FileText)If FileTitleMatch.Count 0 ThenStrip, the, title, tagsFileTitle = Trim (replace (Mid (FileTitleMatch.Item (0), 8), , 1,1,1).)In, case, the, title, is, e
7、mptyIf FileTitle = ThenFileTitle = No Title (& fsFile.Name &)End IfElseCreate, an, alternate, entry, name (if, no, title, found)FileTitle = No Title (& fsFile.Name &)End IfCreate, the, entry, line, with, proper, formattingAdd, the, entry, numberOutputLine = & DocMatchCount &. Add, the, document, nam
8、e, and, linkoutputline = outputline &“ ”outputline = outputline和filetitle &” ”“添加文档信息outputline = outputline &“  ; ;标准匹配”和matchcount&“时间大小:”outputline = outputline和formatnumber(fsfile.size / 1024,2,-1,0,1)和“K字节”outputline = outputline &”最后修改:“formatdatetime(fsfile。datelastmodified,vbshortdat
9、e)和“ ”显示条目写outputline响应。响应。冲洗最后如果fstext。关闭最后如果下一个通过每个子文件夹的迭代和递归调用该程序每个fsfolder2在fsfolder.subfolderssearchfiles fsfolder2。路径下一个集filetitlematch =没有集fstext =没有集fsfile =没有集fsfolder2 =没有集fsfolder =没有端子“-程序:()“-子查询(要查找的字符串)朦胧的我昏暗FKeys昏暗的fitems设置FS = CreateObject(“脚本。FileSystemObject”)集和= new RegExp设置新的正则表
10、达式正则表达式=用正则表达式全局=真的IGNORECASE =真。模式=修剪(要查找的字符串)。结束与和全局=假IGNORECASE =真。模式=“(。| n)* ”结束RootFolder = MapPath(rootfld)服务器。如果对(rootfld,1)“/”然后rootfld = rootfld &”/“最后如果如果是正确的(RootFolder,1)“”然后RootFolder RootFolder &“=最后如果rflen = Len(RootFolder)+ 1searchfiles RootFolder如果matchedcount = 0响应。写“ ; ;没有找到匹配的。 ”最后如果设置正则表达式=没有集和=没有设置FS =无端子% 一个文件搜索1 cellpadding 搜索为; 输入类型为“文本”的大小=“20”值=“ % =请求。QueryString(“查询”)%”name =“查询” “提交”名称=“搜索”值=“搜索” align=“