简体   繁体   中英

Jsoup parsing stuck in inifinite loop

I am using Jsoup to parse some web retrieved pages. For some reasons Jsoup gets into an infinite loop when trying to parse the content at http://higherperspectives.com/keanu-reeves-life/

Here is the code used:

Document document = Jsoup.connect(searchResult.get("link"))
            .timeout(500).followRedirects(false).validateTLSCertificates(false)
            .userAgent("Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36")
            .maxBodySize(0).get();

Elements classElements = document.select("*:containsOwn(${owlSearchTerm.get("class")})");
Elements relationElements = document.select("*:containsOwn(${owlSearchTerm.get("relation")})");
Elements individualElements = document.select("*:containsOwn(${owlSearchTerm.get("individual")})");

The connect method never ends. The connection is successfully established but I guess the problem appears when Jsoup creates the Document object.

Is there a way to skip a situation like this?

I dont really understand why you are using the maxBodySize(0) option. I 've tried it without it and it runs fine and returns the Document.

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