Code:
Imports System.Net
Imports System.Text
Imports System.IO
Public Class Form1
Public Function GetBetween(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, _
Optional ByRef startPos As Integer = 0) As String
Dim iPos As Integer, iEnd As Integer, lenStart As Integer = strStart.Length
Dim strResult As String
strResult = String.Empty
iPos = strSource.IndexOf(strStart, startPos)
iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
End If
Return strResult
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wc As Net.WebClient = New Net.WebClient
Dim ip As String = wc.DownloadString("http://whatismyip.com/automation/n09230945.asp")
ipTxt2.Text = ip
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim myWebClient As New WebClient()
Dim myDatabuffer As Byte() = myWebClient.DownloadData _
("http://whatismyipaddress.com/ip/" & ipTxt2.Text)
Dim download As String = Encoding.ASCII.GetString(myDatabuffer)
Dim HOS As String = GetBetween(download, _
"Hostname:</th><td>", "</td>", 0)
Dim ISP As String = GetBetween(download, _
"ISP:</th><td>", "</td>", 0)
Dim ORG As String = GetBetween(download, _
"Organization:</th><td>", "</td>", 0)
Dim PRO As String = GetBetween(download, _
"Proxy:</th><td><span class=""red"">", "</span></td>", 0)
Dim CIT As String = GetBetween(download, _
"City:</th><td>", "</td>", 0)
Dim REG As String = GetBetween(download, _
"Region:</th><td>", "</td>", 0)
Dim COU As String = GetBetween(download, _
"Country:</th><td>", "<img", 0)
hosTxt.Text = HOS
ispTxt.Text = ISP
orgTxt.Text = ORG
If PRO.Contains("None Detected") Then
proTxt.Text = "None"
Else
proTxt.Text = PRO
End If
citTxt.Text = CIT
regTxt.Text = REG
couTxt.Text = COU
lbl13.Text = "Ready"
tim1.Stop()
Catch ex As Exception
lbl13.Text = "Failed"
End Try
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
Form2.Show()
End Sub
Private Sub CopyAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyAllToolStripMenuItem.Click
Dim copy As String = ipTxt2.Text & vbCrLf & vbCrLf & hosTxt.Text & vbCrLf & vbCrLf & ispTxt.Text & vbCrLf & vbCrLf & orgTxt.Text & vbCrLf & vbCrLf & proTxt.Text & vbCrLf & vbCrLf & citTxt.Text & vbCrLf & vbCrLf & regTxt.Text & vbCrLf & vbCrLf & couTxt.Text
Clipboard.SetData(DataFormats.Text, copy)
MessageBox.Show("Analysis Copied")
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
End Class