Sha256: 3457aec5f3c54cf38a79f5ff50781489b8494731a9b0a6a6b9faea0f963dbfd7

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

class DutchTop40::Scraper

    attr_accessor :title, :name, :listed, :last_weeks_rank

    def self.scrape_songs
        doc = Nokogiri::HTML(open("http://top40.nl"))
        doc.search('.listScroller').search('.top40List').each do |song|
                title = song.search('.songtitle').text.strip
                name = song.search('.artist').text
                listed = song.search('.details').text.split(' | ')[1].gsub(/Aantal weken: /,'').strip
                if song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip  == '-'
                    last_weeks_rank = 'new entry'
                else
                    last_weeks_rank = song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip
                end
                DutchTop40::Songs.new(title, name, listed, last_weeks_rank)
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dutch_top40-0.1.3 lib/dutch_top40/scraper.rb