Reputation: 22264
I'm trying to parse some content from a Twitch.tv website as a learning exercise for Nokogiri.
When fetching the HTML document, I don't get the source that I see on Google Chrome, it seems the content is being loaded via Javascript and not on the initial GET request.
How can I use Nokogiri to parse a list of streams from that website? Or more generically, how can I parse content that is loaded dynamically after the DOM is finished loading?
Upvotes: 1
Views: 1086
Reputation: 54984
The data is json so you don't use nokogiri. For example:
require 'open-uri'
require 'json'
hash = JSON.parse open('http://api.twitch.tv/kraken/games/top?limit=10&on_site=1').read
Upvotes: 5