Hack 24 Keep Track of Auctions Outside of eBay


Use eBay's auction-tracking tools, or create a flexible auction-watching tool better than anything eBay has to offer.

If I bought everything on eBay I wanted, I would've gone broke long ago. But I'm also a collector, and as such, I routinely track many auctions in my various fields of interest, whether or not I actually intend to bid on them.

I would argue that keeping track of auctions is among your most important tasks as a bidder ? especially for items you've won ? if for no other reason than to ensure that you eventually receive everything you've paid for. Tracking auctions is also an essential part of sniping (see [Hack #21]) as well as selling (see [Hack #33]). If you're really after something specific, you may want to track completed auctions that didn't sell so you can find them easily when they're relisted. And sometimes you may want to keep track of an auction's progress purely for the sake of curiosity.

3.6.1 Using eBay's Tracking Tools

The Bidding/Watching tab of My eBay is where most people turn to track their auctions. The Items I'm Bidding On list and the Items I've Won and Items I Didn't Win lists are all updated automatically whenever you place a bid or an auction on which you've bid closes, respectively. These lists include all the vitals, such as the auction titles, amounts of your bids, end dates, and closing prices.

By default, the Items I've Won and Items I Didn't Win lists show only auctions that have ended in the past few days, but you can increase their range to up to 30 days by typing the desired number of days in the box at the top of each list. And like search results, all the lists on this page can be sorted by clicking the hyperlinked column headers.

You can clean out these lists by ticking the checkboxes next to one or more auction titles and clicking Delete. However, when you delete an auction, its entry disappears into the ether with no means of retrieval; instead, you'll have to search by bidder for your own auctions (see Chapter 2) to get a complete listing of your bids. A better way to shorten these lists is to simply decrease the number of days back they go.

The Items I'm Watching list, also on the Bidding/Watching page, is a very handy tool, but it works somewhat differently from the others. It will remain empty until you choose to "watch" an auction: simply go to any auction (or fixed-price listing) page and click "Watch this item." A message then appears confirming that item is now being tracked in My eBay; click the link to view the updated list. The Watching list is easy to use and adequate if you never track more than a few items at a time.

The eBay toolbar [Hack #19] sports a few additional features that work in conjunction with the Items I'm Watching list, such as watch alerts and bid alerts that remind you when auctions you're watching or have bid on are about to end.

3.6.2 If You Want It Done Right . . .

As useful as eBay's tools are, I've found that none of them completely meets my needs. For example:

  • You can watch a maximum of 30 auctions at a time. When you reach the limit, you have to manually delete watched items before you can add more.

  • Auctions appear in the lists for no longer than 30 days, even though they remain in the eBay system for about 3 months.

  • You can't add completed auctions to your Watching list (although closed auctions do remain in your Watching list for 30 days).

  • There's no way to prioritize items in your Watching list, which would be useful for differentiating items on which you're planning to bid and those about which you're simply curious.

  • There's no way to add auctions to the Items I've Won list, which would be useful if you've decided to complete a transaction outside of eBay.

  • The Bidding/Watching page can be cumbersome to use. For example, the way entries are divided into auctions won, auctions lost, etc., has a certain logic to it, but doesn't necessarily end up being as convenient as a single, unified list of auctions would be.

These limitations have prompted me to come up with something better: a fully customizable, web-based, off-site list of auctions with none of the limitations of eBay's tools. The following is based on a tool I created for my own use and have used every day since.

There are two parts to this hack: a Perl script, used to store and display your personal list of auctions, and the link, used to activate the script and add the auction at which you're currently looking.

3.6.3 The Link

The first task is to create an easy way to add any given auction to your custom list, an alternative to the Watch This Item link on auction pages. This is accomplished by placing the following snippet of JavaScript in a button on your browser's Links bar (make sure the text appears all on one line):


You can name the new link anything you like, such as "Watch Auction" or simply "Track." (See [Hack #13] for more information on the Links bar.)

The first few bits of the code are used to instruct your browser to open a new browser window and execute the code inside the parentheses, but it's the stuff that follows that concerns us. First comes the URL of your tracking tool, so you'll need to change www.ebayhacks.com to the name of your own server, /exec to the name of your executable folder (often /cgi-bin), and track.pl to the filename of your script (discussed in the following section). The second half of the URL, after the question mark (?), is composed of three arguments that are passed to your script, separated by ampersands (&):


JavaScript automatically inserts the auction URL (location.href) and page title (document.title) as arguments to pass to the script. One of the neat little tricks of this code is how it works with eBay's auction URL, which also includes arguments separated by ampersands:


When this URL is passed to your script with the other arguments, it is automatically split into these two arguments:


and thus the auction number is conveniently separated for us!

3.6.4 The Script

The second half of this hack is a script written in Perl, which interprets the information it receives from the JavaScript link (see the previous section), stores all your auctions in a file, and then displays a properly sorted list.

This script requires the Time::ParseDate Perl module, part of David Muir Sharnoff's Time-modules-2003.0211 distribution (search.cpan.org/perldoc?Time::ParseDate), which is necessary to convert eBay's date notation into something Perl can understand. (See [Hack #17] for installation instructions.) Also required is Steven E. Brenner's cgi-lib.pl Perl library (cgi-lib.berkeley.edu), used to parse the arguments passed from the JavaScript link.


# *** includes ***
use Time::ParseDate;
use POSIX qw(strftime);

# *** variables ***
$selfurl = "http://www.ebayhacks.com/exec/track.pl";     [1]
$localfile = "/usr/local/home/ebaylist.txt";
$timeoffset = 0;
$url = "http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=";
@formatting=("color=#EE0000 STYLE=font-weight:bold",      [2]
                   "color=#000000 STYLE=font-weight:bold", "color=#000000");
$i = 0;
$exists = 0;
$numlevels = 2;     [3]

# *** read stored list ***
open (INFILE,"$localfile");
  while ( $line = <INFILE> ) {
    $line =~ s/\s+$//;
    ($enddate[$i],$priority[$i],$item[$i],$title[$i]) = 
                                                       split(",", $line, 4);
    # *** see if passed auction number is in list already ***
    if (($item[$i] ne "") && ($item[$i] eq $in{'item'})) { $exists = $i; }
close (INFILE);

# *** add latest auction to list, if valid ***
if (($in{'auction'} =~ "ebay.com") && ($in{'item'} != "") && ($exists==0)) { 
  $x = index($in{'title'}, "(");
  $y = index($in{'title'}, ")", $x);
  $z = index($in{'title'}, "-", $y);

  $title = substr($in{'title'}, $z + 2);     [4]
  $enddate = parsedate(substr($in{'title'}, $x + 6, $y - $x - 7));

  ($enddate[$i], $priority[$i], $item[$i], $title[$i]) = 
                                         ($enddate, 2, $in{'item'}, $title);
elsif (($in{'do'} eq "promote")) {
  if ($priority[$exists] < 0) { $priority[$exists] = 0; }
elsif (($in{'do'} eq "demote")) {
  if ($priority[$exists] > 2) { $priority[$exists] = 2; }  
elsif (($in{'do'} eq "delete")) {
  splice @enddate, $exists, 1;
  splice @priority, $exists, 1;
  splice @item, $exists, 1;
  splice @title, $exists, 1;

# *** update list ***
if (($in{'do'} ne "")) {
  open (OUTFILE,">$localfile");
    for ($j = 1; $j <= $i; $j++) {
      print OUTFILE "$enddate[$j],$priority[$j],$item[$j],$title[$j]\n";
  close (OUTFILE);

  print "Location: $selfurl\n\n";
  exit( 0);

# *** sort list ***
@idx = sort criteria 0 .. $i;

# *** display list ***
print "Content-type: text/html\n\n";
print "<table border cellspacing=0 cellpadding=6>\n";

for ($j = 1; $j <= $i; $j++) {
  $formatteddate = 
         strftime("%a, %b %d - %l:%M:%S %p", localtime($enddate[$idx[$j]]));
  $formattedtitle = "<a href=\"$url$item[$idx[$j]]\" target=\"_blank\"><font     [5]

  if (strftime("%v", localtime($enddate[$idx[$j]])) eq 
                                          strftime("%v", localtime(time))) {
    $formattedtitle = "<li>" . $formattedtitle;     [6]
  if ($enddate[$idx[$j]] < time) {
    $formattedtitle = "<strike>" . $formattedtitle . "</strike>";     [7]
  else {
    $timeleft = ($enddate[$idx[$j]] - time) / 60 + ($timeoffset * 60);
    if ($timeleft < 24 * 60) {
      $hoursleft = int($timeleft / 60);
      $minleft = int($timeleft - ($hoursleft * 60));
      if ($minleft < 10) { $minleft = "0" . $minleft; }
          $formattedtitle = $formattedtitle .      [8]
                         " <font size=-1>($hoursleft:$minleft left)</font>";

  print "<tr><td>$formattedtitle</td>";
  print "<td><font size=-1>$formatteddate</font></td>";
  print "<td><a href=\"$selfurl?item=$item[$idx[$j]]&do=promote\">+</a>";     [9]
  print " | <a href=\"$selfurl?item=$item[$idx[$j]]&do=demote\">-</a>";
  print " | <a href=\"$selfurl?item=$item[$idx[$j]]&do=delete\">x</a></td>";
  print "</tr>\n";

print "</table>\n";

sub criteria {
  # *** sorting criteria subroutine ***
  return ($priority[$a] <=> $priority[$b] or $enddate[$a] <=> $enddate[$b])

Save this script as track.pl and place it in your web server's cgi-bin directory, as described in [Hack #94]. Note that the $selfurl and $localfile variables [1] must be modified to match the URL of your script and the location of the local file in which the auction titles are to be stored, respectively. Also, you may need to adjust the $timeoffset variable to compensate for the time zone difference between eBay time (Pacific time) and your computer's clock; e.g., enter 3 if you're in Eastern time (GMT - 5:00).

3.6.5 Running the Hack

With the script in place and the JavaScript link at the ready on your browser toolbar, all that's left is to try it out. Open any auction page on eBay and click the "Track" link on your Links bar. A new window will open, and the auction you were just looking at will appear at the top of the list, as shown in Figure 3-3. Repeat this for as many auctions as you like; there's virtually no limit. You can even track completed auctions and auctions that you haven't won.

Figure 3-3. Track and prioritize auctions with this flexible web-based tool

Click the title of any auction to open the eBay auction page in a new window. Click the [x] link to delete the entry.

Auctions can be prioritized; all new entries start out at the lowest priority and are shown in normal font. Click the [+] link to promote an auction and make its title bold. Click [+] again to promote the auction to the highest level and make its title red and bold. Likewise, click [-] to demote any entry. Higher-priority items appear higher in the list, and all auctions within a certain priority level are sorted by their closing date. I use the lowest priority for auctions on which I don't intend to bid, the medium priority for items I want, and the highest priority for items I've already bid on and won.

Sellers often lower the Buy-It-Now prices of running auctions that haven't received bids, sometimes repeatedly. If you really want an item, it's a good idea to check back a few times before the end of the auction to see if you can snag it before someone else does. (See [Hack #26] and [Hack #50] for more information.)

You can see this hack in action at www.ebayhacks.com.

3.6.6 Hacking the Hack

Naturally, you'll want to customize this hack to suit your needs, which is really this tool's greatest advantage over eBay's Bidding/Watching page. Among the more interesting ways to hack this script are the following:

  • If you're familiar with HTML, you can add pictures and text to your heart's content. Add shading and even column headers (for sorting) to the table. Replace the [+], [-], and [x] links [9] with more interesting icons, and add a splash of color to the page.

  • You can have as many different levels of prioritization as you like. Three levels suit my needs just fine, but you can add more by increasing the $numlevels variable [3]. (Keep in mind that lower numbers mean a higher priority.) The only other thing you'll need to maintain is the @formatting array [2], which contains snippets of HTML code (one for each priority level) that visually differentiate one priority level from another. For details, look up the <font> structure in any HTML documentation (or see [Hack #40]).

  • Using the $item[$idx[$j]] variable [4], you can also add links to bid, leave feedback, and view the bid history.

  • To support multiple users, include another argument in the JavaScript link (Part 1), such as &user=cletus. Then, simply append the username to the filename to create a different auction list file [1] for each user, like this:

    $localfile = "/usr/local/home/ebaylist_\L$in{'user'}.txt";
  • For simplicity, the script retrieves the auction title [4] by parsing the arguments passed to it from the JavaScript link. The main caveat is that if the title contains an ampersand (&) or pound sign (#), the title will be broken apart, and all you'll get is the first portion. Also, the script determines the closing time and date by further parsing the title, and may not work with titles from non-U.S. sites that use a different date notation.

    A more bulletproof (and only slightly more complex) solution to both of these problems would be to use the eBay API to retrieve the auction title and end date, as described in [Hack #86]. This would also enable you to reliably read the seller's name, the current price, and other auction details, all without having to resort to parsing.

  • The script also contains code to add a little "richness" to the tool. For example, completed auctions have crossed-out titles [7], auctions ending today are marked with round bullets [6], and any auction ending within 24 hours shows the time left to bid [8]. I've found these additions to be quite helpful for my purposes, but you may have different needs. For example, if you're in front of the computer only during the day, you can configure the script to highlight auctions ending after 5:00 P.M. so you know you'll have to bid early or set up an automatic snipe (see [Hack #22]).

  • The pop-up window can be customized by modifying the JavaScript code. For example, add the following to the JavaScript line:


    Place the code after 'Hack' but before the two closing parentheses. Make sure to include the comma and enclose the parameters as a whole in single quotes as shown. More information on these parameters can be found in any JavaScript documentation, under the window.open statement.

    Evaluation has їёАexpired.