Skip to content

hpricot helper that scrapes html easily by parser class defined css selector

License

Notifications You must be signed in to change notification settings

maiha/css_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

css_parser
==========

  hpricot helper that scrapes html easily by parser class defined css selector


Example
=======

  class UserParser < CssParser
    css :name, "div#contents span.name"
    css :age , "div#contents span.age"
  end

  parser = UserParser.file('user.html')
  User.new parser.attributes


Formatter
=========

"css" accepts :as option to specify output format.
Let's consider following html.

  <span class=name>
    Maiha
    <span class=nick>(maiha)</span>
  </span>

When the case of :html formatter, this is in default.

  class UserParser < CssParser
    css :name, "span.name"
  end

  UserParser.new(html).name
  # => "Maiha\n<span class=\"nick\">(maiha)</span>"

When the case of :text formatter.

  class UserParser < CssParser
    css :name, "span.name", :as=>:text
  end

  UserParser.new(html).name
  # => "Maiha\n    (maiha)"



Copyright (c) 2008 [email protected], released under the MIT license

About

hpricot helper that scrapes html easily by parser class defined css selector

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages