Class: Kudzu::Agent::Util::TitleParser

Inherits:
Object
  • Object
show all
Defined in:
lib/kudzu/agent/util/title_parser.rb

Class Method Summary collapse

Class Method Details

.parse(response) ⇒ Object


6
7
8
9
10
11
12
13
14
15
# File 'lib/kudzu/agent/util/title_parser.rb', line 6

def parse(response)
  if response.html?
    from_html(response.parsed_doc)
  else
    Addressable::URI.parse(response.url).basename
  end
rescue => e
  Kudzu.log :warn, "failed to parse title: #{response.url}", error: e
  nil
end