Sha256: 4572a1df88c59c9debe3a837bc6038d26afef965dd0f330877cc9fceb4f11601

Contents?: true

Size: 819 Bytes

Versions: 4

Compression:

Stored size: 819 Bytes

Contents

class BillboardTopSongs::Scraper

  def scrape_page
    doc = Nokogiri::HTML(open("http://www.billboard.com/charts/hot-100"))
  end

  def scrape_songs
    self.scrape_page.css("article.chart-row")
  end

  def make_songs
    scrape_songs.each do |content|
      BillboardTopSongs::Song.new(
      "http://www.billboard.com/charts/hot-100",
      content.css("h2.chart-row__song").text,
      content.css("div.chart-row__container > div > a.chart-row__artist").text.split(" ").join(" "),
      content.css("span.chart-row__current-week").text,
      content.css("div.chart-row__last-week > span.chart-row__value").text.split,
      content.css("div.chart-row__top-spot > span.chart-row__value").text.split,
      content.css("div.chart-row__weeks-on-chart > span.chart-row__value").text.split
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
billboard_top_songs-1.0.2 lib/billboard_top_songs/scraper.rb
billboard_top_songs-0.1.2 lib/billboard_top_songs/scraper.rb
billboard_top_songs-0.1.1 lib/billboard_top_songs/scraper.rb
billboard_top_songs-0.1.0 lib/billboard_top_songs/scraper.rb