I’ve been using python to write various bots and crawler for a long time. Few days ago I needed to write some simple bot to remove some 400+ spam pages in Sikumuna, I took an old script of mine (from 2006) in order to modify it. The script used ClientForm, a python module that allows you to easily parse and fill html forms using python. I quickly found that ClientForm is now deprecated in favor of mechanize. In the beginning I was partly set back by the change, as ClientForm was pretty easy to use, and mechanize
‘s documentation could use some improvement. However, I quickly changed my mind about mechanize
. The basic interface for mechanize
is a simple browser object, that litteraly allows you to browse using python. It takes care of handling cookies and such and it got similar form-filling abilities to ClientForm, but this time they are integrated into the browser object.
For future reference for myself, and as another code example to mechanizes
sparse documentation I’m giving below the gist of the simple bot I wrote:
Continue reading mechanize – Writing Bots in Python Made Simple