0.0
No commit activity in last 3 years
No release in over 3 years
Ruby Cheerio is a jQuery style HTML parser, which take selectors as input. This is a Ruby version NodeJS package named 'Cheerio', which is extensively used by crawlers. Please visit the home page for usage details.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Ruby Cheerio - jQuery style HTML parser for ruby

Visit the published gem page at rubygems.org

Installing the GEM

Use 'gem install ruby-cheerio' for adding it to your gem-list

You can add 'gem ruby-cheerio' to your Gemfile and run 'bundle install'.

Sample Code

Adding ruby-cheerio to your code

require 'ruby-cheerio'

jQuery is just a variable here.

jQuery = RubyCheerio.new("<html><body><h1 class='one'>h1_1</h1><h1>h1_2</h1></body></html>")

The .find method on a cheerio object with 'selectors', which can be a class, id, element name or all together.

jQuery.find('h1').each do |head_one|
	p head_one.text
end

The .prop method can return the value of the attribute. Here 'class' is the attribute needed and 'h1' is the selector again.

p jQuery.find('h1.one')[0].prop('h1','class')

You can find some interesting code samples here: Sample Code