3

What are some tips one can keep in mind to speed up jSoup? I am pretty new to using jSoup and any advice about things I should do, things I should avoid, etc. would be most appreciated.

I just want to know some general things so that I won't slow down my own software.

For example, what is faster:

doc.select("[class=foo]:eq(0)").first()

or

doc.select("[class=foo]").first()

or

doc.select("[class=foo]:lt(1)").first()

Stuff like that.

Didier Ghys
  • 30,396
  • 9
  • 75
  • 81
Apothem
  • 405
  • 1
  • 5
  • 12
  • 1
    I'm looking into something similar right now, but my my main "problem" is the endless wait of the .Parse method :(. I think that you can check things like these by printing something in your console, and see how fast you got the result. But for me, I have had no trouble with speed when it comes to the .Select function. – Honnes Feb 24 '12 at 22:46

1 Answers1

1

You may want to try this tip (taken from here):

not great

for (Element link : links)

better

int i;
Element tempLink;
for (i=0;i<links.size();i++) {
   tempLink = links.get(i);
}
Community
  • 1
  • 1
ih8ie8
  • 944
  • 8
  • 23