我正在使用 Nokogiri 进行作业,但我正在努力解决这个问题。它伤害了我的大脑。导致解决方案的任何步骤、提示或示例都很可爱。
最佳答案
这是一个简单的例子:
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
关于ruby - 如何使用 Nokogiri 获取元关键字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9554053/