Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
improved the pulling out of bids by parsing the html from a snapshot …
Browse files Browse the repository at this point in the history
…of the table, instead of using a series of webdriver calls
  • Loading branch information
Rob Schultheis committed Jan 27, 2013
1 parent 4f9cd1e commit c59407b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
csv

*.log
*.swp
*~
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
source :rubygems
gem 'watir-webdriver'
gem 'hpricot'
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GEM
childprocess (0.3.7)
ffi (~> 1.0, >= 1.0.6)
ffi (1.3.1)
hpricot (0.8.6)
multi_json (1.5.0)
rubyzip (0.9.9)
selenium-webdriver (2.29.0)
Expand All @@ -19,4 +20,5 @@ PLATFORMS
ruby

DEPENDENCIES
hpricot
watir-webdriver
14 changes: 10 additions & 4 deletions site_bindings/quibids.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'watir-webdriver'
require 'hpricot'

#this module implements
module QUIBIDS
Expand Down Expand Up @@ -98,12 +99,17 @@ def seconds_left
end


#improve this, have it parse static html to improve the data capture and eliminate live updating problem
def get_new_bids
cur_amt = @last_amt
bids = []
@auction_els[:history].rows.to_a.reverse.each do |bid_row|
x, bidder, amt, type = bid_row.cells.to_a.map {|c| c.text}

#to do this reliably is tricky, the table moves,
#so going row-by-row / cell-by-cell with webdriver calls will cause accuracy issues
# instead, just pull out a snapshot of the html, and parse that out
# its actually faster this way too, and very accurate
hdoc = Hpricot(@auction_els[:history].html)

hdoc.search('//tr').reverse.each do |tr|
bidder, amt, type = tr.search('//td').map {|tr| tr.inner_html}[1..3]
amt = amt.pa_calc_amt
if amt > @last_amt
bids << {
Expand Down

0 comments on commit c59407b

Please sign in to comment.