whytheluckystiff.net/hpricot/ or in my Apress book Practical Ruby Gems.
Coding the eBay Report
Now let??™s look at the code for the example. Since it??™s fairly complicated, I??™ve divided it into
parts. The first part, shown in Listing 6-1, includes the various libraries required and the
setup code. Make sure you set your path to pdflatex.exe appropriately.
Listing 6-1. Average Price Reporter, Part 1 (average_price_report.rb)
require 'rexml/document'
require 'net/http'
require 'uri'
CHAPTER 6 n TRACKING AUCTIONS WITH EBAY 115
require 'hpricot'
(puts "usage: #{$0} keyword1,keyword2 seller1,seller2"; exit) unless ARGV.length>1
keywords=ARGV.shift.split(',')
sellers=ARGV.shift.split(',')
sellers << nil # This line adds an entry that displays all sellers;
# note that you can delete this line if
# you do not want your output to display
# an average for all sellers.
path_to_pdflatex = '/somepath/pdflatex.exe'
# Make sure you insert your path to pdflatex here.
Next is a class, eBaySearch, which the application will use to search eBay for prices, as
shown in Listing 6-2.
Pages:
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176