Class: Detergent::LinkListExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/detergent/link_list_extractor.rb

Overview

Fallback extractor for index pages: link aggregators, front pages, and directories (e.g. the Hacker News front page) where the "content" is a list of links to other pages. The article locator correctly rejects these — link density is its strongest navigation signal — so when it finds nothing, this extractor looks for a substantial collection of title-like links and returns them as a synthetic list node that flows through the normal cleaning and rendering pipeline.

Constant Summary collapse

15
10

Instance Method Summary collapse

Instance Method Details

#extract(body) ⇒ Object

Returns a synthetic

    of the page's title-like links, or nil if the page doesn't look like a link index.



21
22
23
24
25
26
# File 'lib/detergent/link_list_extractor.rb', line 21

def extract(body)
  links = title_like_links(body)
  return nil if links.length < MIN_LINKS

  build_list(body.document, links)
end