Home PCGS Set Registry Forum

PERL Script to download all your true views

TrazTraz Posts: 377 ✭✭✭✭
edited February 9, 2017 7:42AM in PCGS Set Registry Forum

I wrote this really quick to download all my true views. If there is any interest in this I will rewrite it in a compiled language and make it all nice and clean. To get this to work, you need perl installed with HTTP::Tiny and Spreadsheet::Read modules installed. Save this script as a .pl file. Go to your inventory on the PCGS website, and download your inventory to excel file. After that rename it coins.xlsx and dump it in the same folder as this PERL script. Change _Large to _Small, _Medium, or _Max.

If it encounters a row with CERT blank, it will stop, and if there is no true view for that cert # it will save a 2kb file. Easily fixable but I didn't need to worry about it.

use HTTP::Tiny;
use Spreadsheet::Read qw(ReadData);
my $row = 2 ;

my $book = ReadData('coins.xlsx');

do {
print 'A'.$row.' cert number: '.$book->[1]{A.$row};
my $certnumber = $book->[1]{A.$row};
my $url = 'https://images.pcgs.com/TrueView/'.$certnumber.'_Large.jpg';
print "Fetching ".$url;
my $filename = $certnumber.'_Large.jpg';
open my $out, '>', "$filename" or die "Unable to open $filename for writing.\n";
binmode $out;
print {$out} HTTP::Tiny->new->get($url)->{content};
print "...Saved $filename\n";
$row = $row + 1;
} while ($book->[1]{A.$row} != '')

Comments

  • MonsterCoinzMonsterCoinz Posts: 1,518 ✭✭✭✭✭

    Thanks! I've wanted to write something to go through all GreatCollection PCGS listings and save all listings who's coin has a TrueView, but I haven't gotten around to it. Mine would be in C though. I've never learned PERL.

    www.MonsterCoinz.com | My Toned Showcase

    Check out my iPhone app SlabReader!
  • TrazTraz Posts: 377 ✭✭✭✭

    I guess I could write it in c, too. It's as simple as reading the column and fetching the photo. With a customized one I guess you'd pick the excel file, output directories, and so on. Maybe display the photo as it's being downloaded or whatever.

    If there was interest I could whip it up in my free time.

Sign In or Register to comment.