I just thought I’d share some useful tools for scouting.
I made a list of all matches this year and threw them in a tab-delimited text file for easy parsing: http://rocketscientistblog.com/innovators/FRCmatches.txt
You’d be better off saving the txt file because I can’t guarantee it will always be there.
I’ll post the script how I got it though:
#!/usr/bin/perl
use LWP::Simple;
$url = 'https://my.usfirst.org/myarea/index.lasso?event_type=FRC&year=2012';
$content = get $url;
die "Couldn't get $url" unless defined $content;
@events = $content =~ /eid=(.+)">/g;
foreach (@events) {
s/amp\;//;
$newurl = "https://my.usfirst.org/myarea/index.lasso?page=event_details&eid=" . $_;
$newcontent = get $newurl;
die "Couldn't get $newurl" unless defined $newcontent;
@newmatches = $newcontent =~ /Events\/(.+)\/matchresults.html/g;
foreach(@newmatches) {
$eventurl = "http://www2.usfirst.org/2012comp/Events/" . $_ . "/matchresults.html";
$eventcontent = get $eventurl;
die "Couldn't get $eventurl" unless defined $eventcontent;
$eventName = $_;
@matchmatches = $eventcontent =~ /<TD align=center style="font-family:arial;font-weight:normal;font-size:9.0pt">([0-9]+)<\/TD>/g;
$numMatches = @matchmatches/9;
$lastMatch = 0;
$type = 'q';
for ($i = 0; $i < $numMatches; $i++) {
$match = $matchmatches$i*9 + 0];
$red[0] = $matchmatches$i*9 + 1];
$red[1] = $matchmatches$i*9 + 2];
$red[2] = $matchmatches$i*9 + 3];
$blue[0] = $matchmatches$i*9 + 4];
$blue[1] = $matchmatches$i*9 + 5];
$blue[2] = $matchmatches$i*9 + 6];
$redscore = $matchmatches$i*9 + 7];
$bluescore = $matchmatches$i*9 + 8];
if ($match > $lastMatch && $type eq 'q') {
$type = 'q';
} else {
$type = 'e';
}
$lastMatch = $match;
print "$eventName $type$match $red[0] $red[1] $red[2] $blue[0] $blue[1] $blue[2] $redscore $bluescore
";
}
}
}
I also have a list of all registered teams: http://rocketscientistblog.com/innovators/FRCteams.txt
Same deal goes for the matches list. I can’t guarantee it will always be there.
Here’s the perl script though:
#!/usr/bin/perl
use LWP::Simple;
@teams = ();
$baseUrl = 'https://my.usfirst.org/myarea/index.lasso?page=searchresults&omit_searchform=1&skip_teams=0&-session=myarea:C77D64051149c20F04NUXL2D2C16#FRC_teams';
$content = get $baseUrl;
die "Couldn't get $baseUrl" unless defined $content;
@numTeamArray = $content =~ /\(([0-9]+) found/;
$modulus = @numTeamArray[0] % 250;
if ($modulus == 0) {
$numPages = int(@numTeamArray[0] / 250);
} else {
$numPages = int(@numTeamArray[0] / 250 + 1);
}
for ($i = 0; $i < $numPages; $i++) {
@nextPageArray = $content =~ /a href=\"(.+)\">Next/;
$_ = $nextPageArray[0];
s/amp\;//g;
$nextPage = 'https://my.usfirst.org/myarea/index.lasso' . $_;
@matches = $content =~ /<b>([0-9]+)<\/b><\/a><\/td>/g;
push(@teams, @matches);
$content = get $nextPage;
}
foreach(@teams) {
print "$_
";
}
Be wary of running the scripts too often, as it crawls the usfirst.org site any time you run them. So just run it once, pipe the output to a text file then use the text file. Only update if you have to. Also, if FIRST decides to change their site, the script will probably have to adapt.
Cheers!