资源预览内容
第1页 / 共16页
第2页 / 共16页
第3页 / 共16页
第4页 / 共16页
第5页 / 共16页
第6页 / 共16页
第7页 / 共16页
第8页 / 共16页
第9页 / 共16页
第10页 / 共16页
亲,该文档总共16页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
制作一个个人搜索引擎(源码)(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, program, 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 ValidFiles = 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 MatchCountDim 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), vBTextCompare) 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 MatchCount 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, emptyIf 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, name, 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,vbshortdate)和“ ”显示条目写outputline响应。响应。冲洗最后如果fstext。关闭最后如果下一个通过每个子文件夹的迭代和递归调用该程序每个fsfolder2在fsfolder.subfolderssearchfiles fsfolder2。路径下一个集filetitlematch =没有集fstext =没有集fsfile =没有集fsfolder2 =没有集fsfolder =没有端子“-程序:()“-子查询(要查找的字符串)朦胧的我昏暗FKeys昏暗的fitems设置FS = CreateObject(“脚本。FileSystemObject”)集和= new RegExp设置新的正则表达式正则表达式=用正则表达式全局=真的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=“
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号