Sha256: fa0586ba3ba6953dca63a0a7c6454d70b4fe33399eb8a1fdbc248be314942992
Contents?: true
Size: 888 Bytes
Versions: 1
Compression:
Stored size: 888 Bytes
Contents
class BillboardHot100::Scraper def self.scrape_songs songs = [] index = Nokogiri::HTML(open("https://www.billboard.com/charts/hot-100")) index.css("div.chart-list-item").each do |song| songs << { rank: song.css(".chart-list-item__rank").text.strip, title: song.css(".chart-list-item__title-text").text.strip, artist: song.css(".chart-list-item__artist").text.strip, last_week: song.css(".chart-list-item__last-week").text.strip, peak_position: song.css(".chart-list-item__weeks-at-one").text.strip, weeks_on_chart: song.css(".chart-list-item__weeks-on-chart").text.strip, lyrics: song.css('div.chart-list-item__lyrics a').map { |link| link['href'] }.join, award: song.css(".chart-list-item__award-icon").text.strip } end BillboardHot100::Song.create(songs) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
billboard_hot_100_CLI-0.2.0 | lib/billboard_hot_100/scraper.rb |