Chopper is a tool to extract elements from HTML by preserving ancestors and CSS rules.
http://github.com/jurismarches/chopper.git
0.6.0