[Kde-bindings] dcop access to html parse tree

Richard Dale Richard_Dale at tipitina.demon.co.uk
Thu Sep 2 08:59:46 UTC 2004


On Wednesday 01 September 2004 23:01, Markus Heller wrote:
> Hi Richard,
>
> > I don't think there is an interface to the 'parse tree of the html page'
> > via docp.
>
> [...]
>
> > I don't think you can do that with just the 'dcop' command line utility
> > and kdialog, but you don't need to write in C++ either. There are some
> > examples of using a KHTMLPart from python and ruby in kdebindings, see:
> >
> > python/pykde/examples/pyKHTMLPart.py
> >
> > korundum/rubylib/examples/rbKHTMLPart.rb
> > korundum/rubylib/examples/RubberDoc.rb
> > korundum/rubylib/examples/kludgeror.rb
> >
> > Then you cold write your own 'custom konqueror' to access the homebanking
> > website. The RubberDoc.rb example has code to walk round the DOM tree,
> > which is the closest thing to your request about needing to access the
> > html parse tree. But I'm not sure if there is an interface to KHTMLPart
> > that allows you to programmatically fill out text fields though.
>
> Thanks a lot for your ideas. Though, I would like to simulate web-based
> access to whatever sites and measure response times. The firm I used to
> work for, sold a tool from a company called "Auditec" that was able to do
> measurements on the COM+ Windows layer. (www.auditec-newtest.com) This way
> it was possible to measure response time for almost all network oriented
> applications and many customers appreciated this.
>
> Especially in times where Service Level Agreements become ever more
> important, measuring application performance is a key issue. Glad enough,
> we have such a great interface with DCOP that allows to trigger
> applications on a script basis. Though, I would like to remote control the
> whole application in a way the end user would use it.
>
> I have opened a wishlist item in bugzilla. If you find this issue
> interesting and important in order to be competitive against the
> InternetExplorer measurement orgies, please feel welcome to vote for it!
>
> http://bugs.kde.org/show_bug.cgi?id=88648
I've been playing with kdcop and Konqueror, and I think you can pretty much do 
what you want to do. You can't parse the html tree, but when I look in kdcop 
there is an interface called 'html-widget2' which corresponds to the current 
page. You can use the nextAnchor() and prevAnchor() functions to go from link 
to link, then activateNode() to do something. You can obtain the complete 
text of the page with 'viewDocumentSource()', although it opens up kwrite 
with the text rather than returning it as a QString.

There is another dcop interface konqueror-mainwindow#1 which has a list of 
actions, including 'cut', 'copy' and 'paste'. These actions have 
corresponding dcop refs which you can obtain. So it should be possible to 
paste text into a particular field, and then call 'activateNode()' as above 
to send the page.

I'll experiment and see if I can write a ruby script to drive konqueror.

-- Richard



More information about the Kde-bindings mailing list