引用本页地址:http://www.yongfa365.com/blog/item/iis-log-Analyzer-vbs.htm
'
名称:iis日志搜索引擎相关访问次数统计vbs版
' 作者:柳永法
' 网址:http://www.yongfa365.com/blog/item/iis-log-Analyzer-vbs.htm
' 日期:2007-6-18
' 使用方法:把这个文件存为:iislogAnalyzer.vbs,然后运行便可
Str = InputBox ( " 输入日志文件路径,当前文件可直接输入文件名 " )
If Str <> "" Then
Str = readfile(Str)
Function readfile(filename)
Set FSO = CreateObject ( " Scripting.FileSystemObject " )
Set cnt = FSO.OpenTextFile(filename, 1 , True )
readfile = cnt.ReadAll
End Function
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches
RetStr = 0
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each Match in Matches
RetStr = RetStr + 1
Next
RegExpTest = RetStr
End Function
bots = " Baiduspider|Googlebot|yahoo|sogou|YodaoBot|msnbot|iaskspider "
bots = Split (bots, " | " )
For i = LBound (bots) To UBound (bots)
x = x & bots(i) & " : " & RegExpTest(bots(i), Str) & vbCrLf & vbCrLf
Next
MsgBox (x)
End If
' 作者:柳永法
' 网址:http://www.yongfa365.com/blog/item/iis-log-Analyzer-vbs.htm
' 日期:2007-6-18
' 使用方法:把这个文件存为:iislogAnalyzer.vbs,然后运行便可
Str = InputBox ( " 输入日志文件路径,当前文件可直接输入文件名 " )
If Str <> "" Then
Str = readfile(Str)
Function readfile(filename)
Set FSO = CreateObject ( " Scripting.FileSystemObject " )
Set cnt = FSO.OpenTextFile(filename, 1 , True )
readfile = cnt.ReadAll
End Function
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches
RetStr = 0
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each Match in Matches
RetStr = RetStr + 1
Next
RegExpTest = RetStr
End Function
bots = " Baiduspider|Googlebot|yahoo|sogou|YodaoBot|msnbot|iaskspider "
bots = Split (bots, " | " )
For i = LBound (bots) To UBound (bots)
x = x & bots(i) & " : " & RegExpTest(bots(i), Str) & vbCrLf & vbCrLf
Next
MsgBox (x)
End If

本文介绍了一种使用VBScript分析IIS日志,统计搜索引擎访问次数的方法。通过对日志文件进行处理,利用正则表达式匹配相关记录,实现对搜索引擎访问的详细统计。
176

被折叠的 条评论
为什么被折叠?



