Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Scouting (http://www.chiefdelphi.com/forums/forumdisplay.php?f=36)
-   -   Useful things for scouting (http://www.chiefdelphi.com/forums/showthread.php?t=107235)

Michael Hill 08-07-2012 15:02

Useful things for scouting
 
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/innov...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:
Code:

#!/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\t$type$match\t$red[0]\t$red[1]\t$red[2]\t$blue[0]\t$blue[1]\t$blue[2]\t$redscore\t$bluescore\n";
                }
        }
}

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:

Code:

#!/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 "$_\n";
}

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!


All times are GMT -5. The time now is 16:44.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi