简体   繁体   中英

JSoup runs very slow

I'm trying to use Jsoup to parse html from a website to extract img elements, but it runs very slowly

  try {
        Document doc = Jsoup.connect(webUrl).get();
        Elements imgElements = doc.select("img");
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

Log: Time run finish 11289.0

Jsoup loads the image over the internet so it will take as long as it takes to fetch the page over internet and parse it.

You should try loading the page locally and from file and see if there's somekind of complexities in the document which causes the Jsoup to take a lot of time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM