in reply to Re: Naive idea : using XSH with WWW::Mechanize::Firefox, to make faster XPath queries ?
in thread Naive idea : using XSH with WWW::Mechanize::Firefox, to make faster XPath queries ?

Thanks for pointing at this library.
But then i guess that, as this HTML::TreeBuilder::LibXML library seems to parse only the HTML content, i lose the advantage of WWW::Mechanize::Firefox, which is to take Javascript into consideration.

Just for the sake of curiosity, the Tree look_downs() and the Xpath queries seem to then parse exactly the same information here (the HTML source code); i am wondering whether there is any advantage in using XPath queries rather than Tree's look_down() ? Is it not exactly equivalent ? I guess the XPath queries take less lines to write, though.
Please tell me when i'm wrong :o)

  • Comment on Re^2: Naive idea : using XSH with WWW::Mechanize::Firefox, to make faster XPath queries ?

Replies are listed 'Best First'.
Re^3: Naive idea : using XSH with WWW::Mechanize::Firefox, to make faster XPath queries ?
by Anonymous Monk on Feb 06, 2012 at 12:37 UTC
    i lose the advantage of WWW::Mechanize::Firefox
    You don't. Navigate with Mechanize, parse/query with TreeBuilder.

      As said here 951038 by Corion :
      "WWW::Mechanize::Firefox only works with Firefox. There is no way to make HTML::TreeBuilder::XPath objects work with it."

      WWW::Mechanize::Firefox->xpath() returns MozRepl::RemoteObject, which are i think internal (to Firefox) Javascript objects.
      While HTML:TreeBuilder::XPath returns and deals with HTML::Element, which are extracted from the HTML source, and thus don't take Javascript into account.
      Is that right?

      I am still curious about the utility of using both XPath and Tree. Is it any different from using a Tree on its own?

        PS : i'll try to use HTML::TreeBuilder::LibXML and see what difference it makes with a tree in terms of :
        - algorithm;
        - language fluidity and readability ( shall i call this "poetry" ? );
        - speed;
        and report my results here.