This is too risky. See if you can use pyquery instead. If you haven't used it, look at some of the tests for supersearch that Adrian wrote. It's basically just like jQuery but in python.