Extract some JSON using Nokogiri

Sun picture Sun · Nov 28, 2011 · Viewed 9.9k times · Source
require 'open-uri'
require 'json'
require 'nokogiri'

doc = Nokogiri::HTML(open("http://www.highcharts.com/demo/"))

puts doc

But I want to be able to extract the json from this webpage, using regular expressions doesn't seem to work, and how to do extract JSON through XPath?

Answer

Reactormonk picture Reactormonk · Nov 28, 2011
require 'open-uri'
require 'json'
doc = JSON.parse(open("http://www.highcharts.com/demo/"))