How do you fetch the contents of meta name="description" content="....." with Scrubyt ?
require 'rubygems'
require 'scrubyt'
data = Scrubyt::Extractor.define do
fetch 'http://www.allegro.pl/'
head '//head' do
description '//meta[@name="description"]'
end
end
puts dat开发者_如何学编程a.to_xml
What is the the correct way ?
If you want the value of the content attribute try:
head '//head' do
description '//meta[@name="description"]/@content'
end
//meta[@name="description"]
selects the meta tag whose name attribute is equal to "description" but then you also need to select the value of the content attribute.
精彩评论