|
- Sub Test()
- Dim strPath As String
- Dim ObjStream As Object, objReg As Object, strPat As String
- Dim objMatchs As Object, objMatch As Object
- Dim strTemp As String, arrResult As Variant
- Dim lngRows As Long, lngIndex As Long
-
- strPath = ThisWorkbook.Path & "\index.html"
-
- Set ObjStream = CreateObject("Adodb.Stream")
- With ObjStream
- .Mode = 3
- .Type = 1
- .Open
- .LoadFromFile strPath
- .Position = 0
- .Type = 2
- .Charset = "UTF-8"
- strTemp = .readtext
- End With
-
- Set ObjStream = Nothing
-
- strPat = "<!--<span.*?>(.*?)</span></td>-->(.*\n)*?.*?受影响主机</th>\n.*?<td.*?>(.*)\n(.*\n)*?.*?详细描述</th>\n.*?<td>((.*\n)*?.*?)</td>\n(.*\n)*?.*?解决办法</th>\n.*?<td>((.*\n)*?.*?)</td>"
- Set objReg = CreateObject("VBScript.RegExp")
- With objReg
- .Global = True
- .Pattern = strPat
- End With
- Set objMatchs = objReg.Execute(strTemp)
- lngRows = objMatchs.Count + 1
- ReDim arrResult(1 To lngRows, 1 To 5)
- arrResult(1, 1) = "序号"
- arrResult(1, 2) = "漏洞名称"
- arrResult(1, 3) = "受影响主机"
- arrResult(1, 4) = "详细描述"
- arrResult(1, 5) = "解决办法"
- lngIndex = 2
-
- For Each objMatch In objMatchs
- arrResult(lngIndex, 1) = lngIndex - 1
- arrResult(lngIndex, 2) = objMatch.subMatches(0)
- arrResult(lngIndex, 3) = objMatch.subMatches(2)
- arrResult(lngIndex, 4) = objMatch.subMatches(4)
- arrResult(lngIndex, 5) = objMatch.subMatches(7)
- lngIndex = lngIndex + 1
- Next
- Sheet1.Range("A1").Resize(lngRows, 5) = arrResult
- End Sub
复制代码 |
|