ruby on rails - scrape json from viewsource page -
so i'm trying scrape json exists in website source , use in own site.
heres example site: view-source:http://www.viagogo.co.uk/theatre-tickets/musicals/the-lion-king/the-lion-king-london-tickets/e-1545516
if partway down there var eventlistings
i code exists in var
so far have this:
url = "http://www.viagogo.co.uk/theatre-tickets/musicals/the-lion-king/the-lion-king-london-tickets/e-1545516" doc = open(url).read
any ideas how can this?
thanks
the code have far (basically) function using open-uri
ruby standard library. standard library module, require 'open-uri'
@ top of file in use it.
open::uri
treats job give contents of file. if comfortable using tools search raw text particular contents looking for, may enough. there few gems, though, assume html , provide special support finding html elements , inspecting contents. this post uses mechanize
in turn built on top of nokogiri
. easier write working code when using library, aware installing nokogiri may difficult in staging or production environment when making decision use it.
Comments
Post a Comment