/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

  1. require 'rubygems'
  2. require 'nokogiri'
  3. dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
  4. require File.join(dir, 'httparty')
  5. require 'pp'
  6. class HtmlParserIncluded < HTTParty::Parser
  7. def html
  8. Nokogiri::HTML(body)
  9. end
  10. end
  11. class Page
  12. include HTTParty
  13. parser HtmlParserIncluded
  14. end
  15. pp Page.get('http://www.google.com')