Parsing a web page with Jsoup. Why is the behavior on Android different?

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

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

If I run this code in the sample desktop application, get the html code with 2050 lines (length: 292782, i.e. CORRECT). Same JSoup library.

Can someone explain to me why?

+4
source share
1 answer

Desktop User Agent Configuration

  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 correct html code.

Thanks Tom Reznik

+1
source

Source: https://habr.com/ru/post/1502874/


All Articles