Sha256: bf679f4364bf18ed21335160568cba4c1800adfd8c9a379d477cca4f92490b1f

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

class EbayPetSuppliesSpider < Spidey::AbstractSpider
  handle "http://pet-supplies.shop.ebay.com", :process_home
  
  def process_home(page, default_data = {})
    page.search("#AllCats a[role=menuitem]").each do |a|
      handle resolve_url(a.attr('href'), page), :process_category, category: a.text.strip
    end
  end
  
  def process_category(page, default_data = {})
    page.search("#ResultSetItems table.li td.dtl a").each do |a|
      handle resolve_url(a.attr('href'), page), :process_auction, default_data.merge(title: a.text.strip)
    end
  end
  
  def process_auction(page, default_data = {})
    image_el = page.search('div.vi-ipic1 img').first
    price_el = page.search('span[itemprop=price]').first
    record default_data.merge(
      image_url: (image_el.attr('src') if image_el),
      price: price_el.text.strip
    )
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spidey-0.1.0 examples/ebay_pet_supplies_spider.rb
spidey-0.0.4 examples/ebay_pet_supplies_spider.rb