我正在尝试使用Ruby和Nokogiri。
我已经想出如何打开本地html文档并按类名选择节点:
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::HTML(open("file"))
puts doc.css('a.target')
如何在没有我选择的节点的情况下转储文档?
应该:
doc.css('a.target').remove
puts doc.at('html').to_s