Skip to content

Instantly share code, notes, and snippets.

@miawgogo
Created October 11, 2015 22:23
Show Gist options
  • Save miawgogo/bfdee6aeabfff6cc87ce to your computer and use it in GitHub Desktop.
Save miawgogo/bfdee6aeabfff6cc87ce to your computer and use it in GitHub Desktop.
#Ioan Loosley, CC0
import urllib2
f = open('lastip', "r+")
pubipsite = urllib2.urlopen("http://ipecho.net/plain")
pubip = pubipsite.read()
lastip = f.read()
if pubip != lastip:
#put code here
print "Ip changed to", pubip
f.seek(0)
f.write(pubip)
else:
print "no change"
f.seek(0)
f.write(pubip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment