What is python-webkit?see http://www.gnu.org/software/pythonwebkit/

使用webgtk是个不错的选择

one scenario is about how to access a html page dom objects?

There are 2 solutions:

  1. get dom object in python directly.
        def _view_load_finished_cb(self, view, frame):
    
            doc = frame.get_dom_document()
            nodes = doc.getElementsByTagName('body')
            body = nodes.item(0)
    
            d = doc.createElement("div")
            b = doc.createElement("Button")
            b.innerHTML = "hello"
            b.onclick = self._button_click_event
            d.appendChild(b)
            txt = doc.createTextNode("hello world")
            body.appendChild(txt)
            body.appendChild(d)
            body.tabIndex = 5
            #body.addEventListener("mouseover", self._mouse_over_event, False)
            body.onmouseover = self._mouse_over_event
  2. run WebView.execute_script()
    #username
    script=’document.getElementById(“username1”).value = “%s”;’ % userName
    print script
    view.execute_script(script)

ref:

  1. http://askubuntu.com/questions/97430/connect-webkit-webview-form-to-a-python-callback
Advertisements