2

In Visual Basic, I'm making a program that will send me an email with the IP address of my laptop (just for fun).

The only way that I can think of getting my external IP address is to look at the source for ipchicken.com

It's easy to pull the text down but how do I isolate my IP address?

Note: The IP Address in the source is around line 36, but that is subject to change. Here's the link for all Chrome users: view-source:http://ipchicken.com/

MPelletier
  • 16,256
  • 15
  • 86
  • 137
nick
  • 425
  • 2
  • 4
  • 10
  • check out this question: http://stackoverflow.com/questions/1069103/how-to-get-my-own-ip-address-in-c – Nicolas78 Aug 06 '13 at 20:13
  • As far as he is asking for his public IP address, this won't work – Deblaton Jean-Philippe Aug 06 '13 at 20:29
  • Remember that your computer can, technically, be on many networks. There is no concept of a single "external" IP address in networking, just an address a connection is being made to and from - which may or may not get mangled by NAT but neither end of the connection usually cares. (P2P protocols notwithstanding.) So it's indeed the correct approach to check your address as seen by some suitable outer host. Or using NAT-PMP but that's probably overkill here. – millimoose Aug 06 '13 at 21:12
  • 1
    www.youtube.com/watch?v=hkDD03yeLnU – Kevin Aug 06 '13 at 21:32

3 Answers3

3

Use http://icanhazip.com/

It returns just the string with IP.

Yuriy Galanter
  • 38,833
  • 15
  • 69
  • 136
1

Maybe you can check what is done over here : http://htmlagilitypack.codeplex.com/

If you want to know how to reach a node inside the HTML, use your favorite browser, right click on the IP adress on the website -> inspect element -> copy CSS path (or XPath path)

Here is a sample you might need http://htmlagilitypack.codeplex.com/SourceControl/latest#Trunk/Samples/GetDocLinks/GetDocLinks.cs

Deblaton Jean-Philippe
  • 11,188
  • 3
  • 49
  • 66
1

I found the answer to my own question:

You can use this RegEx to look for the pattern of an IP:

 \b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b

The one above searches for the pattern xxx.xxx.xxx.xxx where "xxx" is a number ranging from 0 to 255.

You can find a tutorial here.

nick
  • 425
  • 2
  • 4
  • 10