I think he’s scraping someone else’s site.
You obviously can’t do this with Ruby alone, as there is no headless web browser written entirely in Ruby (that’s just nonsense)
If you can get phantomjs working on your production site, that’s probably the way to go. Look deep into the internals of Capybara to understand how it drives phantomjs. With phantomjs, you basically have a headless web browser and you can use Capybara’s DSL to access parts of the page, including evaluating scripts and parsing the DOM.
Just keep in mind phantomjs is an actual executable so it needs to be compiled and built for your production environment explicitly, which might be a little tricky depending on where your site is.
But a little birdie told me a few months ago that the phantomjs team has decided that once Chrome has a headless mode, which I believe is forthcoming, they plan to abandon phantomjs in favor of Chrome’s headless mode. Not sure if that’s really true or when that will happen.