Hirbod Behnam Hirbod Behnam -5 years ago 228
Vb.net Question

Get IP From Google

I'm writing an app in vb.net that needs public IP address in text only format. I'd knew there is lots of site that give you your IP in text format. But where is always a chance of being closed or getting out of service. But the Google will not ever stop! Now I want to get my ip from google searching. For example if you search "my ip" in google it will bring your ip like this:
Sample of search
Is anyway to get IP from Google?

Answer Source

Thanks guys but I found a way: At first import some namespaces:

Imports System.Net
Imports System.Text.RegularExpressions

Now lets write a function:

Dim client As New WebClient
Dim To_Match As String = "<div class=""_h4c _rGd vk_h"">(.*)"
Dim recived As String = client.DownloadString("https://www.google.com/search?sclient=psy-ab&site=&source=hp&btnG=Search&q=my+ip")
Dim m As Match = Regex.Match(recived, To_Match)
Dim text_with_divs As String = m.Groups(1).Value
Dim finalize As String() = text_with_divs.Split("<")
Return finalize(0)

It's now working and live!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download