Question

DynDNS requires a login to an account once a month to keep the free domains active. Is it possible to write simple script (in Linux) to do this? The login page is this.

Was it helpful?

Solution

If you want to write it in python and host the script on a server such that it runs indefinetaly, you can use the Mechanize library to log in for you and the time built in to do it once a month. Mechanize: http://stockrt.github.io/p/emulating-a-browser-in-python-with-mechanize/ Time: http://docs.python.org/2/library/time.html Free hosting: https://www.heroku.com/

OTHER TIPS

You mean like this:

import re
import mechanize

username = "username"
password = "password"
success_verification_text = "Log Out"

br = mechanize.Browser()
response = br.open("https://account.dyn.com/")


#select the login form
for form1 in br.forms():
    form = form1
    break;

br.select_form(nr=0)

form["username"] = username
form["password"] = password

response = br.submit()


if success_verification_text in response.read():
    print "SUCCESS"
else:
    print "FAILED"

https://gist.github.com/mandarl/6007396

If you want to login successfully you will need to select login form. Form ID changes between requests (loginNNN) so it's best to search for it by name.

Working example (requires mechanize):

import re
import mechanize

username = "xxx"
password = "xxxxxx"
success_verification_text = "Log Out"

br = mechanize.Browser()

response = br.open("https://account.dyn.com/")

# select the login form
cnt = 0
for frm in br.forms():
    if str(frm.attrs["id"]).find("login") != -1:
        form = frm
        break
    cnt += 1

br.select_form(nr=cnt)

form["username"] = username
form["password"] = password

response = br.submit()

if success_verification_text in response.read():
    print ("SUCCESS")
else:
    print ("FAILED")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top