Class: Readability::Document
- Inherits:
-
Object
- Object
- Readability::Document
- Defined in:
- lib/readability/document/get_best_candidate.rb
Instance Method Summary collapse
-
#get_best_candidate(remove_unlikely_candidates = :default) ⇒ Object
This is basically the “content” method, shortened to just pull the top candidate element.
Instance Method Details
#get_best_candidate(remove_unlikely_candidates = :default) ⇒ Object
This is basically the “content” method, shortened to just pull the top candidate element.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/readability/document/get_best_candidate.rb', line 4 def get_best_candidate(remove_unlikely_candidates = :default) @remove_unlikely_candidates = false if remove_unlikely_candidates == false @html.css("script, style").each { |i| i.remove } remove_unlikely_candidates! if @remove_unlikely_candidates transform_misused_divs_into_paragraphs! candidates = score_paragraphs([:min_text_length]) best_candidate = select_best_candidate(candidates) best_candidate[:elem] rescue NoMethodError nil end |