Python how to get your public ip address


SUBMITTED BY: alemotta

DATE: April 8, 2017, 8:05 p.m.

FORMAT: Text only

SIZE: 329 Bytes

HITS: 531

  1. Python how to get your public ip address
  2. import urllib
  3. import re
  4. print "we will try to open this url, in order to get IP Address"
  5. url = "http://checkip.dyndns.org"
  6. print url
  7. request = urllib.urlopen(url).read()
  8. theIP = re.findall(r"d{1,3}.d{1,3}.d{1,3}.d{1,3}", request)
  9. print "your IP Address is: ", theIP

comments powered by Disqus