Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- # fast easy tool to grab prices from ebay and compare to sold prices of similar
- # or same items
- #
- # Usage: ./cheapfinds.pl <search term buying> <search term sold> <maximum buying price default 9999999>
- #
- # Searches in the ebay Health care Lab and Life Sciences category
- # can be changed easily by modifying he URLs below
- #
- # Default for search term sold is search term buying
- # only does first 200 items sorted by lowest price first
- # price includes shipping to zipcode 60615 change zipcode below
- my %buy = ();
- my %sell = ();
- $zipcode = 60615;
- if(!$ARGV[0])
- {
- print "Usage: ./cheapfinds.pl <search term buying> <search term sold> <maximum buying price default 9999999> \n";
- print "Searches in the ebay Health care Lab and Life Sciences category \n";
- print "can be changed easily by modifying he URLs in the code\n";
- print "Zipcode default for shipping is 60615 change in code\n";
- die;
- }
- if(!$ARGV[1]) { $ARGV[1] = $ARGV[0]; }
- if(!$ARGV[2]){ $ARGV[2] = 9999999; }
- $search = $ARGV[0];
- $search =~ s/[^A-z0-9\-\s]\n\t//;
- $search =~ s/\s/+/g;
- $searchsold = $ARGV[1];
- $searchsold =~ s/[^A-z0-9\-\s]\n\t//;
- $searchsold =~ s/\s/+/g;
- $url[0] = "http://www.ebay.com/sch/i.html?_odkw=$search&_ipg=200&_sop=15&_osacat=11815&_from=R40&_nkw=$search&_sacat=11815&_clu=2&_fcid=1&_localstpos=$zipcode&_stpos=$zipcode&gbr=1";
- $url[1] = "http://www.ebay.com/sch/i.html?_odkw=$searchsold&_ipg=200&_sop=15&_osacat=11815&_from=R40&_nkw=$searchsold&_sacat=11815&_clu=2&_fcid=1&_localstpos=$zipcode&_stpos=$zipcode&gbr=1&LH_Complete=1&LH_Sold=1&rt=nc";
- $x = 0;
- $output[0] = "ebaybuy.html";
- $output[1] = "ebaysold.html";
- foreach $uri (@url)
- {
- if($x == 0) {print "-----Selling-----\n"; }
- else { print "-----Already Sold-----\n"; }
- #get webpages
- `/usr/bin/curl -s -A GoogleBot "$url[$x]" -o "$output[$x]"`;
- #grep out info
- @title = `grep title= $output[$x] | grep -v hidden | grep -v Content`;
- #parse out each item
- foreach $tit (@title)
- {
- @name = split(/\=/, $tit);
- @namesbetter = split(/\'/,$name[5]);
- if($namesbetter[1])
- {
- #find price and shipping
- @parseprice = `grep -A 35 "$namesbetter[1]" $output[$x] | grep -A 15 price`;
- foreach $p (@parseprice)
- {
- if($p =~ /\$/g)
- {
- $p =~ s/[^0123456789.]//g;
- if($x == 0){ $buy{$namesbetter[1]} = $buy{$namesbetter[1]} + $p; }
- else { $sell{$namesbetter[1]} = $sell{$namesbetter[1]} + $p;}
- }
- }
- }
- }
- #sort and output prices
- if($x == 0)
- {
- foreach $key (sort {$buy{$a} <=> $buy{$b}} keys %buy)
- {
- if($buy{$key} <= $ARGV[2]){ print "$key : $buy{$key}\n";}
- }
- }
- else
- {
- foreach $key (sort {$sell{$a} <=> $sell{$b}} keys %sell)
- {
- print "$key : $sell{$key}\n";
- }
- }
- print "\n\n";
- $x++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement