Sha256: c89df2604f85cb6e890be4f556983c495255e1d421f40cee4b1e60084ca8e3d3

Contents?: true

Size: 814 Bytes

Versions: 3

Compression:

Stored size: 814 Bytes

Contents

class Libri::Awards
    attr_accessor :name, :url
    
    def self.all
        self.scrape_barnes_noble
    end

    def self.scrape_barnes_noble
        html = "https://www.barnesandnoble.com/b/books/awards/_/N-29Z8q8Z1d6q"
        awards_page = Nokogiri::HTML(open(html))

        # awards.name = awards_page.css("ul#sidebar-section-0 li a").text
        # awards.url = awards_page.css("ul#sidebar-section-0 li a").attribute("href").value

        awards_array = []
        awards = {}

        awards_page.css("ul#sidebar-section-0 li a").take(15).each { |award|
            awards = {
                :name => award.text.chomp,
                :url => "https://www.barnesandnoble.com" + award.attribute("href").value
            }
            awards_array << awards
        }
        awards_array
    end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
libri-0.2.1 lib/libri/awards.rb
libri-0.1.1 lib/libri/awards.rb
libri-0.1.0 lib/libri/awards.rb