开发者

Scrubyt fetch metadata

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜