Friday, February 16, 2007

Script to get a lot of eBay user ids

To get enough user ids to use for my feedback script I made this perl script:

#!/usr/bin/perl

use LWP::Simple;

$url = "http://search.ebay.com.au/_W0QQfrtsZ0";
$_=get($url);
$number_of_uids = $ARGV[0];
#$number_of_uids = 1000;

do
{
while($_=~m/<h3 class=\"ens fontnormal\"><a href=\"(http:\/\/cgi\.ebay[^\"]*)\"/g)
{
$counter++;
#print "$counter: $1\n";
$item_page = $1;
$uid = get_uid($item_page);
$userids{$uid}++;
}
if($_=~m/<span class=\"next\"><a href=\"([^\"]*)/g)
{
$_=get("http://search.ebay.com.au" . $1);
}
else
{
print "Can't find & get next page of items\n";
}
}while (scalar(keys(%userids))<$number_of_uids);

foreach $uid (keys %userids)
{
print "$uid\n";
}

sub get_uid
{
my $page=shift;
$item_data=get($page);
if($item_data=~m/http:\/\/myworld\.ebay\.com\.au\/([^\/]*)/g)
{
$this_uid = $1;
}
else
{
print "Can't find user id on page $page\n";
}
$this_uid;
}

No comments: