Created
April 29, 2019 13:10
-
-
Save thebitbrine/c614f4fde3f443a4eb58cf2dbd657ecb to your computer and use it in GitHub Desktop.
Fetches external IP address from google.
This file contains 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 string GoogleWhatsMyIP() | |
{ | |
var Response = new System.Net.WebClient() { Encoding = System.Text.Encoding.UTF8 }.DownloadString("https://www.google.am/search?q=whats+my+ip&hl=en"); | |
var m = new System.Text.RegularExpressions.Regex("((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])").Match(Response); | |
if (m.Success) | |
return m.Groups[1].ToString(); | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment