-1

I need to parse one site, but the contents are dynamically generated by Javascript. Is there a way to parse content produced by javascript using Jsoup?

<form method="post" action="../ScreenResolution.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZHfXW6EsrLhbTy9klStsYFtE87Sw" /> 

<script src="/js/framework/WorkWithCookies.js" type="text/javascript"></script><script type="text/javascript">var iScreenWidth = window.screen.width; var iOutcomesGroupsPerRow = 1; if (1280 < iScreenWidth) { if (1680 < iScreenWidth) iOutcomesGroupsPerRow = 3; else iOutcomesGroupsPerRow = 2; } var objClassInstance = new WorkWithCookies('lsoutcomesgroupsperrow'); objClassInstance.WriteCookie(iOutcomesGroupsPerRow, null, null); window.location.href = window.location.href;window.location.reload();</script>
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="2E0D1D88" />
</form>
mbbce
  • 2,245
  • 1
  • 19
  • 31
  • 2
    Your question appears to be missing the very essence of a question – Dave Richardson Mar 01 '16 at 10:13
  • If you need to parse site, then just do it. – waxtah Mar 01 '16 at 10:16
  • Scripts is writing everything on the page, and i can't read the page througth jsoup. – Роман Неретин Mar 01 '16 at 10:31
  • repeating your statement in a comment does not help to clarify what you want to do. I would suggest to formulate a question (hint - it ends with a `?`). Provide also what you expect to be the result of the parsing. For me it is not clear if you try to parse the contents of the script tag, or if the JavaScript loads/renders the actual page that you want to parse. If the latter case is true, you are out of luck, since JSoup does not interpret/run JavaScript. Look into selenium webdriver if you need this kind of functionality. – luksch Mar 01 '16 at 10:48
  • 1
    Possible duplicate of [Jsoup Java HTML parser : Executing javascript events](http://stackoverflow.com/questions/7344258/jsoup-java-html-parser-executing-javascript-events) – Raedwald Mar 01 '16 at 21:57
  • This site has a search function. Use it before posting a new question. – Raedwald Mar 01 '16 at 21:57

1 Answers1

1

As of this writing (Jsoup 1.8.3), it's not possible to parse a webpage that need a script to build its content.

Jsoup is an HTML parser. It doesn't support Javascript. If you want to parse webpages built with client side script, you can use tools like ui4j or Selenium.

Stephan
  • 41,764
  • 65
  • 238
  • 329