vbs- Set fso = CreateObject("Scripting.FileSystemObject")
- Set dict = CreateObject("Scripting.Dictionary")
-
- downloader "http://bbs.tt365.net.cn/viewthread.php?tid=161145", "E:\test\aaa.htm"
-
- Set oDOM = GetObject("E:\test\aaa.htm", "htmlfile")
- Do Until oDOM.readyState="complete" : WScript.Sleep 200 : Loop 'complete
- Set tags = oDOM.getElementsByTagName("td")
- for each tag in tags
- if 1=InStr(tag.Id,"postmessage_") then
- 'WScript.echo tag.innerText
- StrStrReg tag.innerText, "【([^【】]+)】"
- end if
- next
-
- Set ts = fso.OpenTextFile("result.txt", 2, true)
- for each key in dict.Keys()
- 'WScript.echo key
- ts.WriteLine key
- next
- ts.Close()
-
- function downloader(url, file)
- dim XMLHTTP, AdoStrm
- Set XMLHTTP = CreateObject("Microsoft.XMLHTTP")
- XMLHTTP.Open "GET", url, false
- XMLHTTP.Send()
- set AdoStrm = CreateObject("ADODB.Stream")
- AdoStrm.Mode = 3
- AdoStrm.Type = 1
- AdoStrm.Open()
- AdoStrm.Write XMLHTTP.ResponseBody
- AdoStrm.SaveToFile file, 2
- end function
-
- function StrStrReg(srcStr, subStr)
- dim regEx, Matches, Match, ret
- set regEx = CreateObject("VBScript.RegExp")
- regEx.Pattern = subStr
- regEx.Global = true
- regEx.IgnoreCase = false
- set Matches = regEx.execute(srcStr)
- for each Match in Matches
- 'ret = ret & Match.subMatches(0) & vbCrLf
- Catch Match.subMatches(0)
- next
- StrStrReg = ret
- end function
-
- function Catch(txt)
- for each key in dict.Keys()
- if InStr(key,txt) then exit function
- next
- dict.Add txt, 1
- end function
复制代码
|