0

I'm trying to use HtmlUnit to access Youtube-mp3.org, to pass it a YouTube URL from my program. The problem is that this site uses mostly JavaScript, and HtmlUnit throws all kinds of errors when trying to access it.

Does anyone know of any way to add third party JavaScript support to HtmlUnit or know about another Java based headless browser that I could use that supports JavaScript?

Thanks.

1 Answers1

0

I do not know of an other javascript supporting headless browser. Often it is save to ignore Javascript exceptions:

webClient.getOptions().setThrowExceptionOnScriptError(false);

You can also try to change the BrowserVersion HtmlUnit pretends to be, this sometimes solves the problem because some servers sent different javascript depending on the browser the request comes from. INTERNET_EXPLORER seams to work most often, but also try the other ones defined in BrowserVersion.

e.g.

WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_11);
MrSmith42
  • 9,961
  • 6
  • 38
  • 49