Class: LegendasTV::Crawler

Inherits:
Object
  • Object
show all
Defined in:
lib/legendas_tv/crawler.rb

Class Method Summary collapse

Class Method Details

.documentObject



8
9
10
# File 'lib/legendas_tv/crawler.rb', line 8

def document
  Nokogiri::HTML(open("#{LegendasTV::BASE_URL}"))
end

.highlightsObject



20
21
22
23
24
25
26
27
28
# File 'lib/legendas_tv/crawler.rb', line 20

def highlights
  subtitles = []
  document.css("td#conteudodest div[style] div.Ldestaque[onmouseover]").each_with_index do |subtitle_content, i|
    #We need to ignore the first 20, because this is the most_downloaded subtitles
    next if i < 20
    subtitles << LegendasTV::Subtitle.generate_from_nokogiri(subtitle_content)
  end
  subtitles
end

.most_downloadedObject



12
13
14
15
16
17
18
# File 'lib/legendas_tv/crawler.rb', line 12

def most_downloaded
  subtitles = []
  document.css("td#conteudodest div#maisbaixados div[onmouseover]").each do |subtitle_content|
    subtitles << LegendasTV::Subtitle.generate_from_nokogiri(subtitle_content)
  end
  subtitles
end