我正在用 nokogiri 抓取一个 html 页面,我想去掉所有样式属性。
我怎样才能做到这一点?(我没有使用 Rails,所以我不能使用它的 sanitize 方法,我不想使用 sanitize gem,因为我想将黑名单删除而不是白名单)
html = open(url)
doc = Nokogiri::HTML(html.read)
doc.css('.post').each do |post|
puts post.to_s
end
=> <p><span style="font-size: x-large">bla bla <a href="http://torrentfreak.com/netflix-is-killing-bittorrent-in-the-us-110427/">statistica</a> blabla</span></p>
我希望它是
=> <p><span>bla bla <a href="http://torrentfreak.com/netflix-is-killing-bittorrent-in-the-us-110427/">statistica</a> blabla</span></p>