Search code examples
javascriptjavahtmlunit

HtmlUnit stucks on js compile


I run this code

val client = new WebClient(BrowserVersion.CHROME)
val url = "https://belovo.drom.ru/jaguar/f-pace/26324638.html"
val req = new WebRequest(new URL(url))
client.getPage[HtmlPage](req)

Used version of HtmlUnit

<dependency>
   <groupId>net.sourceforge.htmlunit</groupId>
   <artifactId>htmlunit</artifactId>
   <version>2.28</version>
</dependency>

Loading of page stucks on compilation https://c.rdrom.ru/js/DromContacts.min.js?3176009243

This js code is very obfuscated, maybe for this reason it happens.

This lines in log

[2017-12-25 17:15:21,657] WARN  [main] Obsolete content type encountered: 'application/x-javascript'.
[2017-12-25 17:15:21,658] TRACE [main] Javascript compile https://c.rdrom.ru/js/DromContacts.min.js?3176009243

and then nothing happens for long time (5 min).

Have someone faced with such problem?


Solution

  • I got this in the past for some pages. Because HtmlUnit does not render the content some width/height methods are returning more or less fixed values. And some clever javascript tires to layout text using a loop that cuts the text and then checks the width again. In my case this leads to an endless loop.

    If there is some time during the next days i will try your example.