如何使用Scrubyt获取meta name =“description”content =“.....”的内容?
require 'rubygems'
require 'scrubyt'
data = Scrubyt::Extractor.define do
fetch 'http://www.allegro.pl/'
head '//head' do
description '//meta[@name="description"]'
end
end
puts data.to_xml
正确的方法是什么?
答案 0 :(得分:2)
如果您想要内容属性的值,请尝试:
head '//head' do
description '//meta[@name="description"]/@content'
end
//meta[@name="description"]
选择 name 属性等于“description”的元标记,但您还需要选择 content 属性的值。< / p>