The Perl Auctioneer The Code Slide 19
[PREV] [NEXT]

The Code

auction_request();

my %link = (

home => "www.ebay.co.uk",
search => "http://search.ebay.co.uk/search/search.dll?MfcISAPICommand=GetResult&ht=1&SortProperty=MetaEndSort&ebaytag1code=3&currdisp=1&SortProperty=MetaEndSort",
auction => "http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem",
bid => "http://cgi.ebay.co.uk/aw-cgi/eBayISAPI.dll",
);

sub auction_request {
my $self = shift;
my $hash = shift;
$self->{content} = undef; # just in case of leftovers

# build the browser object
$self->{browser} = LWP::UserAgent->new() unless($self->{browser};
my $browser = $self->{browser};

# build the request string
my $uri = new URI($links{auction});
my $qry = $uri->query();
$qry .= "&item=$hash->{key}";
$uri->query($qry);

# send & receive request
$self->{response} = $browser->get($uri->canonical());

# return true/false on success/failure
return 0 unless $self->{response}->is_success;
return 1;
}

© 2003 Barbie barbie@missbarbell.co.uk Home http://birmingham.pm.org/