举例:- url = "http://lolbox.duowan.com/playerDetail.php?serverName=%E5%AE%88%E6%9C%9B%E4%B9%8B%E6%B5%B7&playerName=%E6%88%91%E6%98%AF%E4%BB%96%E5%B9%B2%E7%88%B9"
- Set http = CreateObject("MSXML2.XMLHTTP")
- http.Open "GET", url, false
- http.Send
-
- pattern = "(被赞|被拉黑) +(\d+)|>(战斗力)<[\s\S]*?>(\d+)<"
- MsgBox GetData(http.ResponseBody, pattern)
-
- Function GetData(bin, ByVal pattern)
- with CreateObject("ADODB.Stream")
- .Mode = 3
- .Type = 1
- .Open
- .Write bin
- .Position = 0
- .Type = 2
- .Charset = "utf-8"
- txt = .ReadText
- End with
- Set re = New RegExp
- re.Pattern = pattern
- re.Global = true
- For Each m in re.Execute(txt)
- If m.SubMatches(0) <> "" Then
- s = s & m.SubMatches(0) & vbTab
- s = s & m.SubMatches(1) & vbCrLf
- Else
- s = s & m.SubMatches(2) & vbTab
- s = s & m.SubMatches(3) & vbCrLf
- End If
- Next
- GetData = s
- End Function
复制代码
|