javascript execution from Python script

Paul Rubin phr-n2002b at
Tue Aug 27 16:29:57 CEST 2002

Justin Guerin <jguerin at> writes:
> I administer a 3rd party software program that has a web based
> interface.  I want to automate some of the repetitive tasks I find
> myself doing often, but I can't get directly to the internals, so I
> figured I could write a script to drive the web based interface.
> Many pages contain javascript, and most of the scripting can be done
> by massaging the javascript source, but as for the rest, I'd rather
> not write unique code for it.  After all, I can't really control
> when the interface changes.

Really, dealing with interface changes will need your attention whether
or not your program can interpret js.

Generally the simplest approach is for you to examine the JS and figure
out what it's doing, and program your script to act accordingly.  For
example, if the JS is highlighting buttons on rollover, ignore that.
Other typical JS runs on the onclick event of a form button.  It
typically validates the form content and then runs form.submit().
So just make your script post the form submit directly.  Etc.

That said, I do think a JS to Python converter would be a worthwhile
thing for someone to write someday.  It wouldn't be trivial but it
wouldn't be terribly hard.

More information about the Python-list mailing list