- '提取bathome主页中的会员数信息
- Set Http = CreateObject("Microsoft.XMLHTTP")
- Http.Open "get","http://www.bathome.net",False
- Http.Send
- MsgBox "批处理之家论坛目前会员人数为:"&vbCRLF&Mid((RegExpTest("会员: <em>[0-9]+",Zhuanhuan(Http.responsebody))),9,100)
- Set Http = Nothing
-
- '创建正则用以搜索关键字符串
- Function RegExpTest(Patrn, String)
- Dim RegEx, Match, Matches
- Set RegEx = New RegExp
- RegEx.Pattern = patrn
- RegEx.IgnoreCase = True
- RegEx.Global = True
- Set Matches = RegEx.Execute(String)
- For Each Match in Matches
- RetStr = RetStr&Match.Value
- Next
- RegExpTest = RetStr
- End Function
-
- '创建转换函数用以转换编码
- Function Zhuanhuan(vIn)
- strReturn = ""
- For i = 1 To LenB(vIn)
- ThisCharCode = AscB(MidB(vIn,i,1))
- If ThisCharCode < &H80 Then
- strReturn = strReturn & Chr(ThisCharCode)
- Else
- NextCharCode = AscB(MidB(vIn,i+1,1))
- strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
- i = i + 1
- End If
- Next
- Zhuanhuan = strReturn
- End Function
复制代码
[ 本帖最后由 batman 于 2011-3-11 23:09 编辑 ] |