Sha256: 0574f82d0cb037228d35efd6bb676a49224995b7717cefb47ca3c836c1a38476
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
class PopularDeals::Scrapper def self.scrap_slickdeals(base_url) doc = Nokogiri::HTML(open(base_url)) all_deals = doc.css("div.dealRow") all_deals.collect do |one_deal| deal = PopularDeals::NewDeals.new deal.title = one_deal.css("div.dealTitle a.track-popularDealLink").text.strip link = one_deal.css("div.dealTitle a").attribute("href").value deal.url = "https://slickdeals.net#{link}" deal.deal_rating = one_deal.css("div.ratingCol div.num").text.strip deal.price = one_deal.css("div.priceCol div.price").text.strip date = one_deal.css("div.dealLinks").first.text.strip new_array = date.split deal.posted = "#{new_array[0]} #{new_array[1]}" deal.save end end def self.deal_page(base_url, input, product_url) product_url = PopularDeals::NewDeals.open_deal_page(base_url, input) deal = {} html = open(product_url) doc = Nokogiri::HTML(html) data = doc.text.strip deal[:name] = doc.css("h1").text.strip deal[:discription] = doc.css(".textDescription").text.strip if doc.at_css("a#largeBuyNow").nil? deal[:purchase] = product_url else deal[:purchase] = doc.at_css("a#largeBuyNow").attr("href") end deal end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
popular_deals-1.1.1 | lib/popular_deals/scrapper.rb |