PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 4ms RepoModel.GetById 4ms app.codeStats 0ms

/examples/nokogiri_html_parser.rb

http://github.com/jnunemaker/httparty
Ruby | 19 lines | 15 code | 4 blank | 0 comment | 0 complexity | 1cbe0a89faf8b794c1ad2372259d9784 MD5 | raw file
 1require 'rubygems'
 2require 'nokogiri'
 3
 4dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
 5require File.join(dir, 'httparty')
 6require 'pp'
 7
 8class HtmlParserIncluded < HTTParty::Parser
 9  def html
10    Nokogiri::HTML(body)
11  end
12end
13
14class Page
15  include HTTParty
16  parser HtmlParserIncluded
17end
18
19pp Page.get('http://www.google.com')