本人的解:- Dim objXML, Url
- Url = "http://www.bathome.net"
- Set objXML = CreateObject("MSXML2.XmlHttp")
- objXML.open "GET", Url, False
- objXML.send()
- Do Until objXML.readyState = 4 : WScript.Sleep 200 : Loop
- Dim objADODB
- Set objADODB = CreateObject("Adodb.Stream")
- objADODB.Type = 1
- objADODB.Mode = 3
- objADODB.Open()
- objADODB.Write objXML.responseBody
- Set objXML = Nothing
- Dim objFSO, Temp
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Temp = objFSO.GetSpecialFolder(2) & "\"
- objADODB.SaveToFile Temp & "bathome.html", 2
- Set objADODB = Nothing
- Dim objHTML, objIH
- Set objHTML = GetObject(Temp & "bathome.html", "HtmlFile")
- Do Until objHTML.ReadyState = "complete" : WScript.Sleep 200 : Loop
- Dim A, B, objStr
- A = Array("最新主题", "最新回复", "热门主题")
- B = Array("发帖ID:", "最新回复ID:", "最新回复ID:")
- For i = 1 To 3
- objIH = objHTML.GetElementByID("homegrids_c_" & i).InnerHtml
- objStr = objStr & "["& A(i - 1) & "]" & vbCrLf & GetInfo(objIH, B(i - 1)) & vbCrLf
- Next
- Set objHTML = Nothing
- objFSO.DeleteFile Temp & "bathome.html"
- objStr = Replace(objStr, "<UL class=textinfolist>" & vbCrLf, "")
- objFSO.OpenTextFile("HomePage.txt", 2, True).Write Replace(objStr, vbLf, vbCrLf)
- Set objFSO = Nothing
- CreateObject("Wscript.Shell").Run "cmd /chomepage.txt", True, False
-
- Function GetInfo(Str1, Str2)
- Dim objRE, Matches, Matche
- Set objRE = New RegExp
- objRE.Global = True
- objRE.IgnoreCase = True
- objRE.Pattern = ".*?"">(.*?)</a.*?(\d{1,}-\d{1,}-\d{1,}).*?"">(.*?)</a.*"
- GetInfo = objRE.Replace(Str1, "主题:$3 " & Str2 & "$1 URL:" & Url & "/thread-$2.html")
- Set objRE = Nothing
- End Function
复制代码
|