Prev | Current Page 177 | Next

David Berube

"Practical Reporting with Ruby and Rails"


result_count = result_count + 1
end
end
As you can see, Hpricot has a very simple interface. You use the divide operator (/) to
extract all of the children of a certain type. The expression hpricot_doc/:SearchResultItem
extracts all of the elements and their children, and you then loop
through them. For each of those items, you extract all of the elements
using the divide operator. Since the divide operator always returns an array??”even when
there??™s just one element??”you then call the first method on that array, extracting the first
element. Next, you call the innerHTML method, which returns the inside text of the element.
Finally, you call to_f on the inside text, which converts it into a float, and then add
the price to the total price.
Note that there is a bit of a trade-off here. eBay web services do not have a feature to
search for listings in the past, so you are limited to searching among currently available
listings. (The documentation does indicate that recently finished auctions may be
included, though.


Pages:
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
Dorota Miśkiewicz Lisa Marie Experience Robert Miles Gary Moore Londonbeat