Go to Post You know how grandmothers get shirts that say "Ask me about my grandchildren"? I want one that says "Ask me about my robotics team." - MissInformation [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 01-04-2003, 19:13
Jack's Avatar
Jack Jack is offline
FIRST Scouting Network
AKA: Andrew Schenk
FRC #0201 (The FEDS)
Team Role: Alumni
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Rochester Hills
Posts: 643
Jack is a jewel in the roughJack is a jewel in the roughJack is a jewel in the rough
Send a message via AIM to Jack
Parsing the USFIRST Champ list

Hey all...

Here is some php code that will parse the usfirst team list for the champ event for you. You can change the echo's to assign the fields to an array which you could insert into your db. If you have any questions, feel free to ask me.

PHP Code:
<?php

//Team Parser for The 2003 FIRST Champ. Event
//Designed by: Andrew Schenk (email: [email]webmaster@feds201.com[/email])
//Code tested on PHP 4.3.1 - (should work on any 4+ version & mabey 3 depending on some functions)

//Known Bugs:
//The current source code for the team website is not correct.  It is missing the "" around the url.  
//If first decides to correct this error do the following to the code:
/*
--find--
echo substr($var, (strpos($var, 'href=')+5), (strpos($var, '>') - strpos($var, 'href=')-5)).'<br />';

--replace with--
echo substr($var, (strpos($var, 'href="')+6), (strpos($var, '">') - strpos($var, 'href="')-6)).'<br />';
*/
//I'm 99% sure that would correct the code, but not sure exactly how they would change it so... who knows?

//to actually use the code, replace the echo statements with an array var and then you could dump that array into your db


//hehe... actually going to include a few comments...

//--get source code from usfirst--//
$source '';

$source_pointer fopen('http://www.usfirst.org/frc/map/FMPro?-db=team%20events.fp5&-lay=web&-format=team_list.htm&event=CMP&event%20year=2003&status=signed%20up&-sortfield=team%20id&-max=all&-find'"r");

if ( 
$source_pointer === false )
{
    die(
'Could not open url');
}

while ( !
feof($source_pointer) )
{
    
$source .= fread($source_pointer1024);
}

fclose($source_pointer);

$x 0//$x is going to be the var to hold our string offset in all the strpos() functions

while ( strpos($source'<TR BGCOLOR="#FFFFFF">'$x) > $x )
{
    echo 
'<hr>';

    
$x strpos($source'<TR BGCOLOR="#FFFFFF">'$x) + 22//find the start of a new record (<tr>) and then offset the pointer to the end of it

    
while ( strpos($source'</TR>'$x) > strpos($source'<TD class="news">'$x) && strpos($source'<TD class="news">'$x) > $x )
    {

        
$x strpos($source'<TD class="news">'$x) + 17//find the start of a new field and offset the pointer to the end

        
$var trim(substr($source$x, (strpos($source'</TD>'$x) - $x))); //assign the field to the var

        
if ( strpos($var'<A') !== false //decide if the var has a link in it
        
{
            echo 
substr($var, (strpos($var'href=')+5), (strpos($var'>') - strpos($var'href=')-5)).'<br />'//get url from link
            
$var strip_tags($var); //return the team name
            
echo $var;
        } else {
            echo 
$var.'<br />'//return a var without a link
        
}

    }

}

//--the end--//

?>
__________________
Team 201 - 2003 Great Lakes Semifinalists & 2003 Archimedes Division Finalists :|: Webmaster of www.feds201.com -> FBI Scouting
Winner of The 2003 ChiefDelphi Web Award for: User That Started The Most Non Chit Chat Threads
Winner of: 2003 FIRST Ventures with 5451.68 End Points

All about me: http://knehcsa.vze.com
**Check out the New FIRST Scouting Network**

Last edited by Jack : 01-04-2003 at 19:16.
  #2   Spotlight this post!  
Unread 01-04-2003, 21:16
AJ Quick's Avatar
AJ Quick AJ Quick is offline
Your Attention Please
FRC #0006 (CogSquad)
Team Role: Alumni
 
Join Date: Oct 2002
Rookie Year: 2001
Location: Minnesota
Posts: 464
AJ Quick has a spectacular aura aboutAJ Quick has a spectacular aura about
I noticed a bug, when it displayed results with a website, it didn't properly phrase the location of the the team. That can easily be fixed with this version:

PHP Code:
<?php

//Team Parser for The 2003 FIRST Champ. Event
//Designed by: Andrew Schenk (email: [email]webmaster@feds201.com[/email])
//Code tested on PHP 4.3.1 - (should work on any 4+ version & mabey 3 depending on some functions)
//Code tested on PHP 4.1.2 - (worked fine)

//Known Bugs:
//The current source code for the team website is not correct.  It is missing the "" around the url.  
//If first decides to correct this error do the following to the code:
/*
--find--
echo substr($var, (strpos($var, 'href=')+5), (strpos($var, '>') - strpos($var, 'href=')-5)).'<br />';

--replace with--
echo substr($var, (strpos($var, 'href="')+6), (strpos($var, '">') - strpos($var, 'href="')-6)).'<br />';
*/
//I'm 99% sure that would correct the code, but not sure exactly how they would change it so... who knows?

//to actually use the code, replace the echo statements with an array var and then you could dump that array into your db


//hehe... actually going to include a few comments...

//--get source code from usfirst--//
$source '';

$source_pointer fopen('http://www.usfirst.org/frc/map/FMPro?-db=team%20events.fp5&-lay=web&-format=team_list.htm&event=CMP&event%20year=2003&status=signed%20up&-sortfield=team%20id&-max=all&-find'"r");

if ( 
$source_pointer === false )
{
    die(
'Could not open url');
}

while ( !
feof($source_pointer) )
{
    
$source .= fread($source_pointer1024);
}

fclose($source_pointer);

$x 0//$x is going to be the var to hold our string offset in all the strpos() functions

while ( strpos($source'<TR BGCOLOR="#FFFFFF">'$x) > $x )
{
    echo 
'<hr>';
    
$loc '';

    
$x strpos($source'<TR BGCOLOR="#FFFFFF">'$x) + 22//find the start of a new record (<tr> ) and then offset the pointer to the end of it

    
while ( strpos($source'</TR>'$x) > strpos($source'<TD class="news">'$x) && strpos($source'<TD class="news">'$x) > $x )
    {

        
$x strpos($source'<TD class="news">'$x) + 17//find the start of a new field and offset the pointer to the end

        
$var trim(substr($source$x, (strpos($source'</TD>'$x) - $x))); //assign the field to the var

        
if ( strpos($var'<A') !== false //decide if the var has a link in it
        
{
            echo 
substr($var, (strpos($var'href=')+5), (strpos($var'>') - strpos($var'href=')-5)).'<br />'//get url from link
            
$var explode("</a>"$var); //by AJ Quick (CogSquad.org)
            
$loc $var[1];
            
$var strip_tags($var[0]); //return the team name
            
echo $var.'<br />'.$loc;
   
$var trim(substr($source$x, (strpos($source'</TD>'$x) - $x))); //assign the field to the var
        
} else {
            echo 
$var.'<br />'//return a var without a link
   
$var trim(substr($source$x, (strpos($source'</TD>'$x) - $x))); //assign the field to the var
        
}

    }

}

//--the end--//

?>


It is really great that you provide teams with these resources. I was totally lost, when it came to doing this, but once I looked at the source for one you did.. it became very easy.

Thanks Jack!
__________________
-AJ Quick (Alum on Team 6)
http://www.HHSRobotics.com/

Place your attention entirely on my voice and try to ignore all the others. It is important to be able to focus on a single source of information while blocking out all the other things competing for your attention.
  #3   Spotlight this post!  
Unread 01-04-2003, 21:55
Jack's Avatar
Jack Jack is offline
FIRST Scouting Network
AKA: Andrew Schenk
FRC #0201 (The FEDS)
Team Role: Alumni
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Rochester Hills
Posts: 643
Jack is a jewel in the roughJack is a jewel in the roughJack is a jewel in the rough
Send a message via AIM to Jack
Hey, thanks for pointing out that error. Your soultion is a bit overcomplacated. I designed the script to be inserted into my MySQL DB. I then changed it so that it could be output to a browser. The real problem was that in forgot the <br /> tag on the end of one of the lines

$var = strip_tags($var); //return the team name
echo $var;

to

echo trim(strip_tags($var)).'<br />'; //return the team name


hehe, yeah... thanks again for catching it. (You way's cool too )

and as you can see in that fix, you might want to make sure that you run all the $var's though trim() to kill any whitespace as i forgot to do a few times.
__________________
Team 201 - 2003 Great Lakes Semifinalists & 2003 Archimedes Division Finalists :|: Webmaster of www.feds201.com -> FBI Scouting
Winner of The 2003 ChiefDelphi Web Award for: User That Started The Most Non Chit Chat Threads
Winner of: 2003 FIRST Ventures with 5451.68 End Points

All about me: http://knehcsa.vze.com
**Check out the New FIRST Scouting Network**
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
POLL: How do you feel about Nationals being in Atlanta?? DanLevin247 Championship Event 63 21-07-2003 19:34
Parsing usfirst Match Data Jack Scouting 0 08-03-2003 02:00
Full list of teams & competitions archiver 2001 14 24-06-2002 00:52
Team list & Events archiver 2000 2 23-06-2002 22:39
Suggested list of things to bring to the regionals Andrew Wyatt Technical Discussion 1 06-03-2002 14:41


All times are GMT -5. The time now is 06:23.

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