How to manipulate the DOM with Ruby on Rails

As the title says, I have some DOM manipulation tasks. For example, I want: - Find all the H1 elements that are blue. - find all text in size 12px. - etc.

How can I do this with Rails?

Thanks..:)

Update

I did some research on extracting web page content based on this article-> http://www.springerlink.com/index/A65708XMUR9KN9EA.pdf

Summary of the step:

  • get the web url I want to extract (one web page)
  • capture some elements of a web page based on some visual rules (example: capture all H1 that are blue )
  • handle elements using my algorithm
  • save the result to my database.

- -

+5
3

HTML rails, Nokogiri.

XPath . h1 "" css- .

require 'nokogiri'
require 'open-uri'

doc = Nokogiri::HTML(open('http://www.stackoverflow.com'))
doc.xpath('//h1/a[@class="blue"]').each do |link|
    puts link.content
end

, dom, JavaScript JQuery. .

+8

, -, ( , , , ..).

, , gecko .

, gecko, getComputedStyle, .

, Ruby on Rails , Rails - .

RubyGnome , , RubyGnome Gtk:: MozEmbed.

+1

All Articles