#!/bin/sh
OUT="/tmp/~ebinfo"
rm -f $OUT > /dev/null 2>&1

wget -q -O $OUT "http://offer.ebay.com/ws/eBayISAPI.dll?ViewBids&item=$1"

#set -x
if [ -s $OUT ] ; then
   cat $OUT | grep -A 2 ";userid=" | while read LINE ; do
      BIDDER=$(echo "$LINE" | grep ";userid=" | sed -e 's/userid/\\/' | cut -f 2 -d "\\" | cut -f 1 -d "<" | sed -e 's/=//' -e 's/\">/(/' )
      if [ "$BIDDER" != "" ] ; then
#         echo "$BIDDER)"
	 read LINE
         BIDDING=$(echo "$LINE" | grep "^<td align" | cut -f 2 -d ">" | cut -f 1 -d "<" )
#         echo "$BIDDING"
	 read LINE
         #   for i in $(grep "^<td>" $OUT1 | cut -f 3 -d ">" | cut -f 1 -d "<") ; do
         DATE=$(echo "$LINE" | grep "^<td>" | cut -f 3 -d ">" | cut -f 1 -d "<")
	 DT=$(date -d "$DATE" +"%a %d %R")
#         echo "$DT"
	 echo "\"$BIDDER)\",\"$BIDDING\",\"$DT\""
      fi
   done
fi
