views:

81

answers:

1

Given a URL, I would like to be able to render the returned HTML to know width and height for each div, fonts' size for each piece of text, color of each element, position of each element on screen, etc.

A possible approach could be traversing the DOM tree with Hpricot and checking CSS style by parsing the associated stylesheet using css_parser gem. But this would not consider default styles, inheritance, floats, etc.

In Java there's Cobra, a Java Web Renderer, which is able to render a web page and query attributes like width, font size, etc. for each fragment. I could use Cobra with JRuby or similar solutions, but prefer a Ruby native tool. Is there any library like this for Ruby?

A: 

RbWebKitGTK

Ignacio Vazquez-Abrams
Looks well, but seems to be an "opaque" widget, i.e., it doesn't provide rendered elements information. How could I get a div's width/position or a piece of text's font size with it?
Jose
I don't actually know. That part of the bindings may not be complete yet.
Ignacio Vazquez-Abrams