VB.NET MAC OUI Поиск - PullRequest
       34

VB.NET MAC OUI Поиск

0 голосов
/ 05 октября 2018

Доброе утро,

Я создал проект vb.NET, который извлекает данные из HTML-файла WireShark, найденного по адресу https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf;hb=HEAD.

До сих пор я был в состояниизагрузите страницу в виде строки и выполните поиск по строке, чтобы убедиться, что в строке найдено «mac».

Я бы хотел, чтобы он искал MAC-адрес и вывел всю строку, на которой появляется MAC.

Например, если я ищу 00-00-00-00-00-00, я бы хотел извлечь всю строку «00:00:00 Xerox Xerox Corporation»

Вот что у меня есть:

Private Sub btn_search_Click(sender As Object, e As EventArgs) Handles btn_search.Click
    Dim mac As String = txt_MAC.Text.ToUpper
    Dim pattern As Regex = New Regex("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$")
    Dim match As Match = pattern.Match(mac)

    If match.Success Then
        mac = mac.Replace("-", ":")
        mac = mac.Substring(0, mac.Length - 9)

        Dim wc As New Net.WebClient
        Dim html As String = wc.DownloadString("https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf;hb=HEAD")
        Dim macIndex = html.IndexOf(mac) 'returns line number in string

        MsgBox("Valid MAC: " & mac)

        If html.Contains(mac) Then
            'Display MAC + Vendor. IE.... 0:00:01   Xerox   Xerox Corporation'
            ' Is there a way to read only the specified line number in the string?
        End If

    Else
        MsgBox("You must enter a valid MAC")
    End If
End Sub

Любая помощь очень ценится.

1 Ответ

0 голосов
/ 05 октября 2018

Хотя и немного небрежно, я смог сделать это с помощью следующего кода:

        Dim wc As New Net.WebClient
        Dim html As String = wc.DownloadString("https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf;hb=HEAD")
        Dim macIndex = html.IndexOf(mac)

        If html.Contains(mac) Then
            txt_result.Text = "Searching... "
            txt_result.Text = html.Chars(macIndex) & html.Chars(macIndex + 1) & html.Chars(macIndex + 2) & html.Chars(macIndex + 3) & html.Chars(macIndex + 4) & html.Chars(macIndex + 5) & html.Chars(macIndex + 6) & html.Chars(macIndex + 7) & html.Chars(macIndex + 8) & html.Chars(macIndex + 9) & html.Chars(macIndex + 10)

Спасибо!

...