The Python Webkit DOM Project makes python a full peer of javascript when
it comes to accessing and manipulating the full features available to
Webkit, such as HTML5. Everything that can be done with javascript,
such as getElementsbyTagName and appendChild, event callbacks through
onclick, timeout callbacks through window.setTimeout, and even AJAX
using XMLHttpRequest, can also be done from python.
https://wiki.python.org/moin/PythonWebKit
可以用PyQtWebKit,官方提供example。应该会有你想要的
I believe this is what you want: http://jeanphix.me/Ghost.py/