Class: Html2rss::HtmlExtractor::Extractors::Iframe

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/html_extractor/enclosure_extractor.rb

Overview

Extracts iframe enclosures from HTML tags.

Class Method Summary collapse

Class Method Details

.call(article_tag, base_url:) ⇒ Array<Hash{Symbol => Object}>

Returns iframe enclosure hashes.

Parameters:

  • article_tag (Nokogiri::XML::Element)

    article container node

  • base_url (String, Html2rss::Url)

    base URL for relative iframe links

Returns:

  • (Array<Hash{Symbol => Object}>)

    iframe enclosure hashes



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/html2rss/html_extractor/enclosure_extractor.rb', line 86

def self.call(, base_url:)
  .css('iframe[src]').filter_map do |iframe|
    src = iframe['src']
    next if src.nil? || src.empty?

    abs_url = Url.from_relative(src, base_url)
    {
      url: abs_url,
      type: RssBuilder::Enclosure.guess_content_type_from_url(abs_url, default: 'text/html')
    }
  end
end