问题
I'm using Nokogiri for an assignment and I'm struggling to figure this out. It's hurting my brain. Any steps, hints, or examples leading to the solution would be lovely.
回答1:
Here is a simple example:
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::HTML("<html><head><meta name=\"Keywords\" content=\"one, two, three\"></head><body></body></html>")
doc.xpath("//meta[@name='Keywords']/@content").each do |attr|
puts attr.value
end
来源:https://stackoverflow.com/questions/9554053/how-to-get-meta-keywords-using-nokogiri