Gabriel and Marcelo are both correct: Rather than writing a script to log in and update your settings with your DNS provider via web scraping, you can simply assign 'www.yourdomain.com' as a CNAME to a free Dynamic DNS hostname with DynDNS.com or No-IP. Both companies offer update client software which synchronize your hostname with your IP address whenever a change occurs, and if you're really interested in writing the script yourself, our update API is open:
https://www.dyndns.com/developers/
You can also find update clients in most Linksys, D-Link and Netgear routers, though software clients are usually more reliable and easier to troubleshoot. We also offer a paid service if you'd prefer to eschew the 'myhostname.dyndns.org' and update your domain directly.