开发者

Scrubyt fetch metadata

开发者 https://www.devze.com 2022-12-08 20:52 出处:网络
How do you fetch the contents of meta name=\"description\" content=\".....\"with Scrubyt ? require \'rubygems\'

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

精彩评论

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