Sha256: f6cd6661ed60b09221c3e5b0bd46252907a7bcc7a35edf1635c4dc22f0cce46e
Contents?: true
Size: 714 Bytes
Versions: 1
Compression:
Stored size: 714 Bytes
Contents
# Craft Craft XML and HTML into objects. ## Examples ```ruby require 'craft' require 'open-uri' class Page < Craft # Use CSS selectors one :title, 'title' # Use XPath many :links, 'a/@href' # Perform transforms on returned nodes many :images, 'img', lambda { |img| img.attr('src').upcase } end page = Page.parse open('http://www.google.com') page.title #=> 'Google' page.links #=> ['http://www.google.com/imghp?hl=en&tab=wi', ...] page.images #=> ['/LOGOS/2012/MOBY_DICK12-HP.JPG'] class Script < Craft one :body, 'text()' end class Page < Craft many :scripts, 'script', Script end page = Page.parse open('http://www.google.com') page.scripts[0].body #=> 'window.google=...' ```
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
craft-0.0.2 | README.md |