我有一个表格的网络查询,它给了我这样的表格:
[C] [D] [E]
[A] Events | IP source | IP destination |
[B] MyEvent (1.10) | 192.168.0.1 | 192.168.0.3 |
给我信息的 Html 代码是关于这种类型的模式:
<table class="wrapper">
<tbody>
<tr>
<td width="100%" valign="top">
<center>
<div id="contenpanel">
<table id="contenttable" class="full_table_of_events">
<tbody>
<tr class="content" oncontextmenu="blablabla",( "src=192.168.0.1&dst=192.168.0.2")></tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
</div>
</center>
</td>
<tr>
</tbody>
</table>
所以我可以通过简单的 c0de .innerText 获得值,innerText 的完整值是:
myEvent (1.10) 192.168.0.1 192.168.0.2
我确实用 msgbox 清除了这个值,我在 excel 中有这个 c0de,它的作用是,看看你有没有在工作表上有鼠标并给一个 Label.form 你得到的标题,我有 3 label.form 的 1 用于事件,1 用于源 IP,1 用于目标 ip,我尝试使用 c0de 查看我拥有的那条线是否存在于桌子上,但没有任何反应。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Eventi.Caption = ActiveCell.Value
Source.Caption = Cells(ActiveCell.Row, ActiveCell.Column + 1)
Destination.Caption = Cells(ActiveCell.Row, ActiveCell.Column + 2)
End Sub
Sub Extract()
Dim URL As String
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim TRelements As IHTMLElementCollection
Dim TRelement As HTMLTableRow
Dim Chkb0x As IHTMLElementCollection
URL = "https://localhost/events/index.cgi"
Set IE = New InternetExplorer
With IE
.navigate URL
.Visible = True
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set HTMLdoc = .document
End With
Set TRelements = HTMLdoc.getElementsByTagName("TR")
MsgBox Eventi.Caption & " " & Source.Caption & " " & Destination.Caption
MsgBox "Search Starting..."
For Each TRelement In TRelements
If Trim(TRelement.innerText) = Eventi.Caption & " " & Source.Caption & " " & Destino.Caption Then
MsgBox "Bingo! You have this event"
End If
Next
End Sub
好吧,我希望有人能看到我做错了什么我只是想知道是否有办法做到这一点。