/
newegg.rb
33 lines (29 loc) · 1.1 KB
/
newegg.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Fletcher
module Model
class Newegg < Fletcher::Model::Base
# A regular expression for determining if a url comes from a specific service/website
def self.regexp
/newegg\.com/
end
# Parse data and look for object attributes to give to object
def parse(data)
super(data)
case doc
when Nokogiri::HTML::Document
# Get Name
self.name = doc.css("#synopsis .grpDesc .wrapper h1 > span").first_string
#self.name = doc.css("#synopsis .grpDesc .wrapper > .span").first_string
# Description - Not always reliable.
self.description = doc.css(".itmDesc > p").first_string
# Get Price (currently disabled because price is displayed after page load)
#parse_price doc.css("li.price-current").attribute("content").content
# # Get Images
self.images = [{:src => doc.css('.mainSlide > img').attribute("src").content}]
self.image = images.first
end
rescue
return nil
end
end
end
end