Go to Post You are joining the greatest family in the world, FIRST, because we all strive to practice GP. - Ken Loyd [more]
Home
Go Back   Chief Delphi > Competition > Rules/Strategy > Scouting
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-07-2012, 15:02
Michael Hill's Avatar
Michael Hill Michael Hill is offline
Registered User
FRC #3138 (Innovators Robotics)
Team Role: Mentor
 
Join Date: Jul 2004
Rookie Year: 2003
Location: Dayton, OH
Posts: 1,572
Michael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond reputeMichael Hill has a reputation beyond repute
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!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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