Class: UrlFinder::HTMLReader

Inherits:
BaseReader show all
Defined in:
lib/url_finder/readers/html_reader.rb

Overview

Find URLs in HTML strings

Instance Attribute Summary

Attributes inherited from BaseReader

#content

Instance Method Summary collapse

Methods inherited from BaseReader

#each, #empty?, #initialize, #to_a, urls

Constructor Details

This class inherits a constructor from UrlFinder::BaseReader

Instance Method Details

#urlsArray<String>

Returns the found URLs

Returns:

  • (Array<String>)

    the found URLs



11
12
13
14
15
16
# File 'lib/url_finder/readers/html_reader.rb', line 11

def urls
  @urls ||= begin
    document = Nokogiri::HTML(content)
    document.css('a').map { |e| e['href'] }.compact
  end
end