public
Description: Miscellaneous toys and scripts
Homepage: http://blog.bleything.net
Clone URL: git://github.com/bleything/miscellany.git
update vgdod for christmas time pages
bleything (author)
Mon Dec 29 13:25:57 -0800 2008
commit  6a6ace5deb0e09a4e3ebaf38e3336936889b751f
tree    80d01dcd20c2c86882164752b6fd8fa287c1fab8
parent  eb331ff8516687bba589a6084d0fbb2cf0cc2566
...
2
3
4
 
5
 
6
7
 
8
9
10
11
12
 
 
 
13
14
15
 
 
16
17
18
...
2
3
4
5
6
7
8
 
9
10
 
 
 
 
11
12
13
14
15
16
17
18
19
20
21
0
@@ -2,17 +2,20 @@
0
 
0
 %w(rubygems hpricot open-uri shorturl).each {|g| require g}
0
 def fetch(url = '') ; return Hpricot(open("http://www.amazon.com" + url)) ; end
0
+def d(msg = '') ; $stderr.puts msg ; end
0
 
0
+d "Fetching amazon.com"
0
 vg_url = fetch.at("a[text()=Video Games]")[:href]
0
-puts " * found video games URL: #{vg_url}" if $DEBUG
0
+d " * found video games URL: #{vg_url}"
0
 
0
-dotd_img = fetch(vg_url).search("img").select {|e| e[:src] =~ /deal-of-the-day/}.first
0
-puts " * found dotd image href: #{dotd_img.parent[:href]}" if $DEBUG
0
-
0
-dotd = fetch(dotd_img.parent[:href])
0
+dotd_img = fetch(vg_url).search("area").select {|e| e[:alt] =~ /Deal of the Day/}.first
0
+d " * found dotd image href: #{dotd_img[:href]}"
0
+dotd = fetch(dotd_img[:href])
0
 
0
 table = dotd.at( "//table.amabot_widget" )
0
 
0
+puts "-" * 80
0
+
0
 puts "Title:      " + table.at( "/tr/td[3]/a" ).inner_text.strip
0
 
0
 puts "Platform:   " + table.at( "/tr[2]/td" ).inner_html.

Comments