Sha256: 6f43a8cca3b04a69a3081dcd7f0c13d5aa190d59e7ce70bbdec26e115962f7c5
Contents?: true
Size: 959 Bytes
Versions: 1
Compression:
Stored size: 959 Bytes
Contents
require 'nokogiri' require 'open-uri' class DayBooks::Scraper attr_accessor :books_array @@books_array = [] def self.books_array @@books_array end def self.empty_books_array @@books_array.clear end def self.get_page(page_url) Nokogiri::HTML(open(page_url)) end def self.get_book_info author_library_url = "https://www.goodreads.com/author/list/19823.Sylvia_Day?page=1&per_page=99999" book_info = self.get_page(author_library_url).css('tr[itemtype="http://schema.org/Book"]') book_info.each do |book| @@books_array << { :title => book.css('.bookTitle span[itemprop=name]').text, :book_url => book.css('a').attribute('href').value } end end def self.get_description(book_url) full_book_url = "https://www.goodreads.com" + book_url doc = self.get_page(full_book_url) book_description = doc.css('div#descriptionContainer span[2]').text book_description end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
day_books-0.1.0 | lib/scraper.rb |