First of all, scrapping and parsing JS from pages is not trivial. It can however be vastly simplified if you use a headless web client instead, which will parse everything for you just like a regular browser would.
The only difference is that its main interface is not GUI/HMI but an API.
For example, you can use PhantomJS with Chrome or Firefox which both support headless mode.
For a more complete list of headless browsers check here.