Skip to Main Content
eBay Hacks
book

eBay Hacks

by David A. Karp
August 2003
Beginner content levelBeginner
368 pages
9h 38m
English
O'Reilly Media, Inc.
Content preview from eBay Hacks

Automatically Relist Unsuccessful Auctions

Save time by automatically relisting auctions that have received no bids or have a reserve that wasn’t met.

Most of the time, when an auction ends without receiving any bids or with a reserve that wasn’t met, sellers end up relisting the item. But this can be rather laborious, especially if you have more than a few auctions to relist.

The following script will relist for you, and when run on a regular basis, say, every day, you’ll never have to manually relist an auction again.

#!/usr/bin/perl
require 'ebay.pl';

$localfile = "autorelist.txt";     [1]
$today = &formatdate(time);
$yesterday = &formatdate(time - 86400);

my $page_number = 1;
PAGE:
while (1) {
    my $rsp = call_api({ Verb => 'GetSellerList',
                  DetailLevel => 8,
                       UserId => $user_id,
                  EndTimeFrom => $yesterday,
                    EndTimeTo => $today,
                   PageNumber => $page_number
    });

    if ($rsp->{Errors}) {
      print_error($rsp);
      last PAGE;
    }
    foreach (@{$rsp->{SellerList}{Item}}) {
      my %i = %$_;
      ($id, $bidder) = @i{qw/Id HighBidder/};

      if ($bidder->{User}{Email} !~ "\@") {     [2]
        open (INFILE,"$localdir/$localfile");
          while ( $line = <INFILE> ) {
            if ($line eq "$id\n") { goto SKIP; }     [3]
          }
        close (INFILE);

        my $rsp = call_api({Verb => 'RelistItem',     [4]
                     DetailLevel => 0,
                          SiteId => $site_id,
                          ItemId => $id
        });
    
        if ($rsp->{Errors}) {
          print_error($rsp)
        } else {
          print "Relisted item $id as #$rsp->{Item}[0]{Id}\n";
          
          open (OUTFILE,">>$localdir/$localfile");
            print OUTFILE "$id\n";     [5] close (OUTFILE); } } } SKIP: last PAGE unless $rsp->{SellerList}{HasMoreItems}; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

eBay Hacks, 2nd Edition

eBay Hacks, 2nd Edition

David A. Karp

Publisher Resources

ISBN: 0596005644Catalog PageErrata