简体   繁体   中英

Parsing webpage with Jsoup. why is the behaviour on Android different?

Document doc = Jsoup.connect(url).get();

If I run this code in Android I get a html code with 535 lines (length:42599).

If I run this code in a sample desktop application get a html code with 2050 lines (length:292782, that is CORRECT. Same JSoup library of course.

Can anyone explain me why?

Setting desktop user agent

            Document doc = Jsoup.connect(URL).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0").timeout(TIMEOUT).get();

I get the right html code.

Thanks to Tom Reznik

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