College football scores.
Was bored tonight so I did a college football page scrape and the original version is only good for the current week. Still needs a bit of work such as better formatting, but you get the idea.
NCAA Scoreboard
Saturday, September 13, 2014
Rice vs Texas A&M
3rd 5:44
1 2 3 4
Rice 0 7 0 7
0-1
7
Texas A&M 7 14 7 28
2-0
Arizona State vs Colorado
Halftime
1 2 3 4
16
Arizona State 14 10 24
....
....
....
--------------------
We usually save data to file for editing
./gcfs.sh > filename
gcfs.sh
[code]
####################################
# Score Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="tcf"
let "flag = 0"
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "www.ncaa.com/scoreboard/football/fbs" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "NCAA Scoreboard"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q "Featured Sections"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "GameCenter"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
-------------------------------
Update: This new version will show past data and scheduled match ups for future weeks.
[code]
####################################
# Score Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="tcf"
let "flag = 0"
let "year = 2014"
let "week = 4"
if [ "$week" -lt "10" ]; then
let "a = 0"
fi
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "www.ncaa.com/scoreboard/football/fbs/$year/$a$week/" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "NCAA Scoreboard"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q "Featured Sections"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "GameCenter"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
NCAA Scoreboard
Saturday, September 13, 2014
Rice vs Texas A&M
3rd 5:44
1 2 3 4
Rice 0 7 0 7
0-1
7
Texas A&M 7 14 7 28
2-0
Arizona State vs Colorado
Halftime
1 2 3 4
16
Arizona State 14 10 24
....
....
....
--------------------
We usually save data to file for editing
./gcfs.sh > filename
gcfs.sh
[code]
####################################
# Score Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="tcf"
let "flag = 0"
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "www.ncaa.com/scoreboard/football/fbs" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "NCAA Scoreboard"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q "Featured Sections"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "GameCenter"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
-------------------------------
Update: This new version will show past data and scheduled match ups for future weeks.
[code]
####################################
# Score Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="tcf"
let "flag = 0"
let "year = 2014"
let "week = 4"
if [ "$week" -lt "10" ]; then
let "a = 0"
fi
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "www.ncaa.com/scoreboard/football/fbs/$year/$a$week/" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "NCAA Scoreboard"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q "Featured Sections"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "GameCenter"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
Comments
Post a Comment