Class: Html2rss::AutoSource::Scraper::SemanticHtml
- Inherits:
-
Object
- Object
- Html2rss::AutoSource::Scraper::SemanticHtml
- Includes:
- Enumerable
- Defined in:
- lib/html2rss/auto_source/scraper/semantic_html.rb,
lib/html2rss/auto_source/scraper/semantic_html/entry_deduplicator.rb
Overview
Scrapes semantic containers via SST: Normalizer → Segmenter → Scoring → SstArticleExtractor.
Defined Under Namespace
Classes: EntryDeduplicator
Constant Summary collapse
Class Method Summary collapse
-
.articles?(parsed_body) ⇒ Boolean
True when at least one semantic container has an eligible anchor.
-
.options_key ⇒ Symbol
Config key used to enable or configure this scraper.
Instance Method Summary collapse
- #each {|article| ... } ⇒ Enumerator<Html2rss::Article>
- #extractable? ⇒ Boolean
-
#initialize(parsed_body = nil, url:, document: nil, link_resolver: nil, **opts) ⇒ SemanticHtml
constructor
A new instance of SemanticHtml.
Constructor Details
#initialize(parsed_body = nil, url:, document: nil, link_resolver: nil, **opts) ⇒ SemanticHtml
Returns a new instance of SemanticHtml.
34 35 36 37 38 39 40 |
# File 'lib/html2rss/auto_source/scraper/semantic_html.rb', line 34 def initialize(parsed_body = nil, url:, document: nil, link_resolver: nil, **opts) @parsed_body = parsed_body @provided_document = document @provided_link_resolver = link_resolver @url = url @permit_unanchored = opts.fetch(:fallback_anchorless, false) end |
Class Method Details
.articles?(parsed_body) ⇒ Boolean
Returns true when at least one semantic container has an eligible anchor.
20 21 22 23 24 25 26 |
# File 'lib/html2rss/auto_source/scraper/semantic_html.rb', line 20 def self.articles?(parsed_body) return false unless parsed_body new(parsed_body, url: 'https://example.com').extractable? rescue ArgumentError false end |
.options_key ⇒ Symbol
Returns config key used to enable or configure this scraper.
16 |
# File 'lib/html2rss/auto_source/scraper/semantic_html.rb', line 16 def self. = :semantic_html |
Instance Method Details
#each {|article| ... } ⇒ Enumerator<Html2rss::Article>
45 46 47 48 49 |
# File 'lib/html2rss/auto_source/scraper/semantic_html.rb', line 45 def each return enum_for(:each) unless block_given? articles.each { yield _1 } end |
#extractable? ⇒ Boolean
53 54 55 56 57 |
# File 'lib/html2rss/auto_source/scraper/semantic_html.rb', line 53 def extractable? ranked_segments.any? rescue ArgumentError false end |