Created
September 4, 2015 13:37
-
-
Save mbrownnycnyc/8b64ba0d53d0f3b3cbeb to your computer and use it in GitHub Desktop.
The beginnings of an Excel macro for IP information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function WhoIs(ByVal tRange As Range, ByVal tItem As String) As String | |
' http://www.mrexcel.com/forum/excel-questions/780655-doing-whois-excel.html | |
Dim xmlhttp As Object | |
Dim r, c As Integer | |
Dim t As String | |
r = tRange.Row | |
c = tRange.Column | |
ip = Cells(r, c).Text | |
Set xmlhttp = CreateObject("msxml2.xmlhttp.3.0") | |
xmlhttp.Open "get", "http://whois.arin.net/rest/nets;q=" & ip & "?showDetails=true&showARIN=false&ext=netref2", False | |
xmlhttp.send | |
t = xmlhttp.ResponseText | |
Select Case UCase(tItem) | |
Case "NETRANGE" | |
t = Mid(t, InStr(t, "<" & "endAddress>") + 12) | |
WhoIs = Left(t, InStr(t, "<") - 1) | |
t = Mid(t, InStr(t, "<" & "startAddress>") + 14) | |
WhoIs = Left(t, InStr(t, "<") - 1) & " - " & WhoIs | |
Case "NAME" | |
t = Mid(t, InStr(t, "<" & "name>") + 6) | |
WhoIs = Left(t, InStr(t, "<") - 1) | |
Case "ORGANIZATION" | |
t = Mid(t, InStr(t, "<" & "orgRef name=") + 14) | |
WhoIs = Left(t, InStr(t, Chr(34)) - 1) & " (" | |
t = Mid(t, InStr(t, "handle=") + 8) | |
WhoIs = WhoIs & Left(t, InStr(t, Chr(34)) - 1) & ")" | |
End Select | |
End Function | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment