Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to speed up Jsoup.parse()?

Tags:

android

jsoup

I am using the all String version of Jsoup.parse():

parse(String html, String baseUri)

Ruling out connectivity speed for benchmarking its performance.

On a typical low-end Android phone, calling Jsoup.parse() on the html String of a not-so-rare long Wikipedia page (~600KB), takes 9 seconds!

My client is not willing to accept this delay and I am thinking of either dumping Jsoup for a different engine, parsing web pages myself (still in Java), or using some C/C++ parser in NDK (if available).

But I prefer continuing to use Jsoup as much as possible.

Is there a way to speed up Jsoup.parse()?

like image 433
Souper Avatar asked Jul 03 '12 20:07

Souper


1 Answers

What I try to do myself with big pages (if it's possible and you only want some information on the page) is try to minimize the text to parse identifying previously the regions that you want and then parse wanted regions with JSoup.

That way you can combine your own parsing in Java to reduce data and then use JSoup for commodity.

like image 86
lujop Avatar answered Nov 16 '22 06:11

lujop