In this article I'll show you how to make a simple IP address notifier. The program will text you your new IP address, in the event that it changes. For those of you with dynamic IPs, this is very useful. I'm constantly frustrated when my IP changes, and it's handy to be notified via text when it happens. To use the program, you'll need Python 2.7 or later, urllib2, and a program called "text" (see this article here to get it).
from urllib2 import urlopen
#imports all required modules
#this is the loop function that allows the code to be re-run every 24 hours
#this is the initial ip, the one you have right now
url = urlopen('http://www.whatismyip.org/')
#starts loop, creates currentIP and url variables
#sets your current ip to currentIP variable
#if the original ip doesn't equal the currentIP...
#text you the new ip address
#and reset the original ip to the current one
#time to sleep until next check
Note: DO NOT change the loop time! "WhatIsMyIP.org" doesn't like bots pinging their server multiple times. The loop time is designed to simulate a real person, and not overload the server with redundant requests.
The program itself is very simple; checks for changes in IP and lets you know via text. But, this program could also check any website for information you'd like, and text it to you. Simply change the URL and which lines the program is identifying and extracting. Of course, ensure the site you are using has no restrictions against bots pinging their servers. If you have any other ideas/suggestions, please comment! :)
Want to start making money as a white hat hacker? Jump-start your hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from cybersecurity professionals.
Other worthwhile deals to check out: