Class: Html2rss::AutoSource::Scraper::Html
- Inherits:
-
Object
- Object
- Html2rss::AutoSource::Scraper::Html
- Includes:
- Enumerable
- Defined in:
- lib/html2rss/auto_source/scraper/html.rb
Overview
Fallback HTML list/cluster scraper via SST pipeline (Normalizer → Segmenter → Scoring::Engine → Html::SstArticleExtractor).
Constant Summary collapse
- DETECTION_BASE_URL =
Absolute base URL used when probe-time detection needs to normalize relative hrefs.
'https://example.com'- DEFAULT_MINIMUM_SELECTOR_FREQUENCY =
Minimum selector frequency required to treat a path as a stable list signal.
2- DEFAULT_USE_TOP_SELECTORS =
Number of most frequent selectors kept for container extraction.
5- TOP_K =
Maximum articles materialized after eligibility filtering.
Scoring::Engine::TOP_K
Class Method Summary collapse
Instance Method Summary collapse
- #each {|article| ... } ⇒ Enumerator
- #extractable? ⇒ Boolean
-
#initialize(parsed_body = nil, url:, document: nil, link_resolver: nil, **opts) ⇒ Html
constructor
A new instance of Html.
Constructor Details
#initialize(parsed_body = nil, url:, document: nil, link_resolver: nil, **opts) ⇒ Html
Returns a new instance of Html.
44 45 46 47 48 49 50 51 |
# File 'lib/html2rss/auto_source/scraper/html.rb', line 44 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 @opts = opts @fallback_anchorless = opts.fetch(:fallback_anchorless, false) end |
Class Method Details
.articles?(parsed_body) ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'lib/html2rss/auto_source/scraper/html.rb', line 28 def self.articles?(parsed_body) return false unless parsed_body new(parsed_body, url: DETECTION_BASE_URL).extractable? rescue ArgumentError false end |
.options_key ⇒ Symbol
23 |
# File 'lib/html2rss/auto_source/scraper/html.rb', line 23 def self. = :html |
Instance Method Details
#each {|article| ... } ⇒ Enumerator
56 57 58 59 60 |
# File 'lib/html2rss/auto_source/scraper/html.rb', line 56 def each return enum_for(:each) unless block_given? articles.each { yield _1 } end |
#extractable? ⇒ Boolean
64 65 66 67 68 |
# File 'lib/html2rss/auto_source/scraper/html.rb', line 64 def extractable? ranked_segments.any? rescue ArgumentError false end |