class DslrShop::Scraper
Public Class Methods
scrape_from_detail(camera)
click to toggle source
# File lib/dslr_shop/scraper.rb, line 16 def self.scrape_from_detail(camera) doc = Nokogiri::HTML(open(camera.url)) camera.discount = doc.search("div.pPrice p span").text.strip camera.type = doc.search("div.product-highlights ul li")[0].text # begin camera.style = doc.search("div.items-group p span")[0].text if doc.search("div.items-group p span")[0] # rescue StandardError # binding.pry # end camera.rewards = doc.search("div.acTwoPercent a").text.gsub(/\s+[a-z]*$/, "") if doc.search("div.acTwoPercent a").size>0 camera end
scrape_from_list(list_url)
click to toggle source
# File lib/dslr_shop/scraper.rb, line 3 def self.scrape_from_list(list_url) doc = Nokogiri::HTML(open(list_url)) camera_nodes = doc.search("div.item.clearfix") camera_nodes.map {|camera_node| camera = DslrShop::Camera.new camera.brand = camera_node.search("div.desc-zone.zone h3 a span")[0].text camera.name = camera_node.search("div.desc-zone.zone h3 a span")[1].text.chomp(" (Body Only)") camera.availability = camera_node.search("p.scAvailabilityTri span").text.strip camera.price = camera_node.search("div.atc-price p span.price").text.strip camera.url = camera_node.search("div.desc-zone.zone h3 a").attr('href').text } end