Wednesday, November 29, 2006

Web Browsing Automation

If you need to keep going to a web page that requires you to log in, then click a series of links, you might be able to automate this process and save a lot of time. Tools like PAMIE and IEUnit let you write simple scripts that will make Internet Explorer visit the site without your intervention.

For example, I use PAMIE which is a library for Python like this:

import cPAMIE
ie = cPAMIE.PAMIE('www.website-to-visit.com')

ie.imageClick('intro.jpg')
ie.textBoxSet('loginName','my_username')
ie.textBoxSet('password', 'my_password')
ie.imageClick('login.jpg')
ie.linkClick('Reports for Today')
ie.linkClick('My Report')

I saved the above commands into a file called 'myreport.py' and whenever I needs to see the report, I just doublick the file and see Internet Explorer do the logging in and clicking for me.

The password is stored in plain text, so this is not very secure if you are sharing your computer with untrusted people. However, if you are not serious about this, it can save you time, especially when your Internet is not fast and you have to wait if you visit the site manually. This way, all the waiting is done by the script, freeing you to do other better things.