Skip to Content
eBay Hacks, 2nd Edition
book

eBay Hacks, 2nd Edition

by David A. Karp
June 2005
Beginner
463 pages
14h 19m
English
O'Reilly Media, Inc.
Content preview from eBay Hacks, 2nd Edition

Automatically Keep Track of Items You’ve Sold

Retrieve and store completed listing data without typing.

As explained in “Keep Track of Items You’ve Sold” [Hack #83] , it’s vital for every seller to keep permanent, off-site records of every single auction he or she has sold.

This script, when run daily [Hack #21] , does it all:

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

	$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, $enddate, $title, $currency, $price, $highbidder) =
		 @i{qw/Id EndTime Title CurrencyId CurrentPrice HighBidder/};
     if (! -e "$localdir/$id") {
	  open (OUTFILE,">$localdir/$id"); 
	  print OUTFILE "[Details]\n"; 
	  print OUTFILE "enddate=$enddate\n"; 
	  print OUTFILE "itemnumber=$id\n"; 
	  print OUTFILE "title=$title\n"; 
	  print OUTFILE "price=$currency$price\n"; 
	  print OUTFILE "bidder=".$highbidder->{User}{UserId}."\n"; 
	  print OUTFILE "bidderemail=".$highbidder->{User}{Email}."\n";
    close (OUTFILE);
	}
   }
	last PAGE unless $rsp->{SellerList}{HasMore Items};
    $page_number++;
 }

This script works similarly to the one in “Automatically Keep Track of Auctions You’ve Won” [Hack ...

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

eBay Hacks

David A. Karp
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 059610068XErrata Page