I need to have live scores from sporting events coming into my site as nodes. The only free info that I can find looks like this.
0rpg,%2021.0%20ppg&nba_s_right1_3=J.%20Johnson%2018.6%20ppg,%203.7%20apg&nba_s_right1_count=3&nba_s_url1=http://sports.espn.go.com/nba/preview?gameId=320210019&nba_s_left2=LA%20Clippers%20at%20Philadelphia%20(7:00%20PM%20ET)&nba_s_right2_1=B.%20Griffin%2021.4%20ppg,%2011.0%20rpg&nba_s_right2_2=L.%20Williams%2015.7%20ppg,%203.7%20apg&nba_s_right2_count=2&nba_s_url2=http://sports.espn.go.com/nba/preview?gameId=320210020&nba_s_left3=Miami%20at%20Washington%20(7:00%20PM%20ET)&nba_s_right3_1=L.%20James%2028.5%20ppg,%206.9%20apg&nba_s_right3_2=N.%20Young%2016.9%20ppg,%201.2%20apg&nba_s_right3_count=2&nba_s_url3=http://sports.espn.go.com/nba/preview?gameId=320210027&nba_s_left4=Boston%20at%20Toronto%20(7:00%20PM%20ET)&nba_s_right4_1=P.%20Pierce%2018.4%20ppg,%205.7%20apg&nba_s_right4_2=A.%20Bargnani%2023.5%20ppg,%206.4%20rpg&nba_s_right4_count=2&nba_s_url4=http://sports.espn.go.com/nba/preview?gameId=320210028&nba_s_left5=Chicago%20at%20Charlotte%20(7:00%20PM%20ET)&nba_s_right5_1=D.%20Rose%2022.0%20ppg,%207.8%20apg&nba_s_right5_2=G.%20Henderson%2015.0%20ppg,%201.8%20apg&nba_s_right5_count=2&nba_s_url5=http://sports.espn.go.com/nba/preview?gameId=320210030&nba_s_left6=Milwaukee%20at%20Cleveland%20(7:30%20PM%20ET)&nba_s_right6_1=B.%20Jennings%2018.9%20ppg,%205.3%20apg&nba_s_right6_2=K.%20Irving%2018.0%20ppg,%205.1%20apg&nba_s_right6_count=2&nba_s_url6=http://sports.espn.go.com/nba/preview?gameId=320210005&nba_s_left7=New%20Jersey%20at%20Detroit%20(7:30%20PM%20ET)&nba_s_right7_1=D.%20Williams%2020.9%20ppg,%208.6%20apg&nba_s_right7_2=G.%20Monroe%2016.4%20ppg,%2010.0%20rpg&nba_s_right7_count=2&nba_s_url7=http://sports.espn.go.com/nba/preview?gameId=320210008&nba_s_left8=Portland%20at%20New%20Orleans%20(8:00%20PM%20ET)&nba_s_right8_1=L.%20Aldridge%2023.3%20ppg,%208.5%20rpg&nba_s_right8_2=E.%20Gordon%2021.0%20ppg,%202.0%20apg&nba_s_right8_count=2&nba_s_url8=http://sports.espn.go.com/nba/preview?gameId=320210003&nba_s_left9=Dallas%20at%20Minnesota%20(8:00%20PM%20ET)&nba_s_right9_1=D.%20Nowitzki%2017.6%20ppg,%206.2%20rpg&nba_s_right9_2=K.%20Love%2025.0%20ppg,%2013.7%20rpg&nba_s_right9_count=2&nba_s_url9=http://sports.espn.go.com/nba/preview?gameId=320210016&nba_s_left10=LA%20Lakers%20at%20New%20York%20(8:00%20PM%20ET)&nba_s_right10_1=Airing%20on%20ESPN&nba_s_right10_2=K.%20Bryant%20NBA%20scoring%20leader&nba_s_right10_3=K.%20Bryant%2029.2%20ppg,%205.3%20apg&nba_s_right10_4=C.%20Anthony%2022.3%20ppg,%204.2%20apg&nba_s_right10_count=4&nba_s_url10=http://sports.espn.go.com/nba/preview?gameId=320210018&nba_s_left11=Indiana%20at%20Memphis%20(8:00%20PM%20ET)&nba_s_right11_1=M.%20Conley%20NBA%20steals%20leader&nba_s_right11_2=M.%20Conley%202.5%20spg,%2012.3%20ppg&nba_s_right11_3=D.%20Granger%2018.3%20ppg,%202.1%20apg&nba_s_right11_4=R.%20Gay%2018.4%20ppg,%202.0%20apg&nba_s_right11_count=4&nba_s_url11=http://sports.espn.go.com/nba/preview?gameId=320210029&nba_s_left12=Oklahoma%20City%20at%20Utah%20(10:30%20PM%20ET)&nba_s_right12_1=Airing%20on%20ESPN&nba_s_right12_2=S.%20Ibaka%20NBA%20blocks%20leader&nba_s_right12_3=S.%20Ibaka%203.0%20bpg,%207.5%20ppg&nba_s_right12_4=K.%20Durant%2027.3%20ppg,%203.4%20apg&nba_s_right12_5=A.%20Jefferson%2018.5%20ppg,%208.9%20rpg&nba_s_right12_count=5&nba_s_url12=http://sports.espn.go.com/nba/preview?
Here are the links to see this content (I do not know what format this is)
http://sports.espn.go.com/nfl/bottomline/scores
http://sports.espn.go.com/nba/bottomline/scores
http://sports.espn.go.com/mlb/bottomline/scores
http://sports.espn.go.com/ncf/bottomline/scores
http://sports.espn.go.com/rpm/bottomline/race
http://sports.espn.go.com/sports/golf/bottomLineGolfLeaderboard
http://sports.espn.go.com/wnba/bottomline/scores
http://sports.espn.go.com/espn/bottomline/news
I have this code but it's not php
#!/usr/bin/python
--->
<!--- Script can be a scheduled task or ran when the user requests it --->
<!--- This script works only with NFL and NCAA Football --->
<!--- Things that might be useful that I know about the String that comes from ESPN for NFL and NCAA Football --->
<!---
1. When the game is over, the matchArray[i].matchDate = "FINAL" OR NEQ "FINAL - OT"
2. When the game is at halftime, the matchArray[i].matchDate = "HALFTIME"
3. These are the only times when matchArray[i].matchDate is not a date, but a string
4. The URL string is updated ever 120 seconds
5. NBA, NHL are a little more tricky because it lists some stats after the game
(Anybody who decides to parse these, please let me know. I don't have the need right now
but I would like to have the code
--->
<!--- Known ESPN URL STRINGS --->
<!---
NFL: http://sports.espn.go.com/nfl/bottomline/scores
NBA: http://sports.espn.go.com/nba/bottomline/scores
MLB: http://sports.espn.go.com/mlb/bottomline/scores
NHL: http://sports.espn.go.com/nhl/bottomline/scores
NCAA Football: http://sports.espn.go.com/ncf/bottomline/scores
GOLF: http://sports.espn.go.com/sports/golf/bottomLineGolfLeaderboard
Nascar: http://sports.espn.go.com/rpm/bottomline/race
WNBA: http://sports.espn.go.com/wnba/bottomline/scores
ESPN Headlines: http://sports.espn.go.com/espn/bottomline/news
--->
<!--- To debug, try removing the cftry's --->
<!--- Set to false to hide the string and url --->
<cfset ShowNFLEspnString = false>
<!--- Set to false to hide the dump of the games --->
<cfset ShowGameDump = false>
<!--- Set to false to hide the Pass | Fail Message --->
<cfset ShowPassFail = false>
<!--- And away... We... GO! --->
<cftry>
<!--- Lets do NFL --->
<cfset espn = "http://sports.espn.go.com/nfl/bottomline/scores">
<cfhttp url="#espn#" method="get" resolveurl="yes" throwonerror="yes" />
<cfset myArray = arrayNew(1) />
<cfset myResult = #CFHTTP.FileContent# />
<cfif ShowNFLEspnString EQ true>
<cfoutput>
<br />
ESPN NFL String URL: <a href="#espn#">#espn#</a><br />
<br />
#myResult#<br />
<br />
</cfoutput>
</cfif>
<cfset j = 1 />
<!---parse the urls, don't touch :)--->
<cfset newResult = #REReplace(myResult, "%20%20", "@", "all")# />
<cfset newResult = #REReplace(newResult, "%20", " ", "all")# />
<cfset newResult = #REReplace(newResult, "%26", "", "all")# />
<cfset newResult = #REReplace(newResult, "[(][0-9][)]", "", "all")# />
<cfset newResult = #REReplace(newResult, "[(][0-9][0-9][)]", "", "all")# />
<cfset newResult = #REReplace(newResult, "[(][A-Z][A-Z][)]", "", "all")# />
<cfset newResult = #REReplace(newResult, "\^", "", "all")# />
<cfset newResult = #REReplace(newResult, "[ \t][a-z][a-z][ \t]", "@", "all")# />
<cfset newResult = #REReplace(newResult, "[(]", "@(", "all")# />
<cfset newResult = #REReplace(newResult, "[()]", "", "all")# />
<!---loop over the urls and store the teams in a array--->
<cfloop list="#newResult#" index="i" delimiters="#chr(38)#">
<!--- Sometimes espn has a item with no teams or scores --->
<!--- If this is the case, a try catch will keep the loop going so it doesn't crash --->
<cftry>
<cfset myArray[j] = listgetat("#i#", 2, "=") />
<cfset j = j + 1 />
<cfcatch>
<!--- Don't care what the extra garbage is --->
</cfcatch>
</cftry>
</cfloop>
<cfset gamesArray = arrayNew(1) />
<cfset j = 1 />
<cfloop from="3" to="#arraylen(myArray)#" index="m" step="3">
<cfset gamesArray[j] = #myArray[m]# & "&" />
<cfset j = j + 1 />
</cfloop>
<!---remove garbage character at the end of the array--->
<cfset delete = #arrayDeleteAt(gamesArray, j-1)# />
<!---turn the array back into a list for fun :)--->
<cfset breakUp = #arrayToList(gamesArray,"")# />
<cfset matchArray = arrayNew(1) />
<cfloop list="#breakUp#" index="z" delimiters="#chr(38)#">
<cftry>
<cfset matchup = structNew() />
<cfset matchup.teamOne = trim(listgetat("#z#", 1, "@")) />
<!--- Get the score start and end places --->
<cfset teamOneScoreStringStart = #findoneof("0123456789",matchup.teamOne)#>
<cfset teamOneScoreStringEnd = #LEN(matchup.teamOne)#>
<!--- Team 1 Score --->
<cfif teamOneScoreStringStart EQ 0>
<cfset matchup.teamOneScore = 0>
<cfelse>
<cfset matchup.teamOneScore =#Mid(matchup.teamOne,teamOneScoreStringStart,teamOneScoreStringEnd)#>
</cfif>
<!--- Remove Score from teamOne String --->
<cfif teamOneScoreStringStart NEQ 0>
<cfset teamOneScoreStringStart = teamOneScoreStringStart - 1>
<cfset matchup.teamOne = #Mid(matchup.teamOne,1,teamOneScoreStringStart)#>
</cfif>
<cfset matchup.teamTwo = trim(listgetat("#z#", 2, "@")) />
<!--- Get the score start and end places --->
<cfset teamTwoScoreStringStart = #findoneof("0123456789",matchup.teamTwo)#>
<cfset teamTwoScoreStringEnd = #LEN(matchup.teamTwo)#>
<!--- Team 2 Score --->
<cfif teamTwoScoreStringStart EQ 0>
<cfset matchup.teamTwoScore = 0>
<cfelse>
<cfset matchup.teamTwoScore =#Mid(matchup.teamTwo,teamTwoScoreStringStart,teamTwoScoreStringEnd)#>
</cfif>
<!--- Remove Score from teamTwo String --->
<cfif teamTwoScoreStringStart NEQ 0>
<cfset teamTwoScoreStringStart = teamTwoScoreStringStart - 1>
<cfset matchup.teamTwo = #Mid(matchup.teamTwo,1,teamTwoScoreStringStart)#>
</cfif>
<cfset matchup.matchDate = trim(listgetat("#z#", 3, "@")) />
<cfcatch>
<!--- Don't care, just make sure it doesn't crash --->
</cfcatch>
</cftry>
<cfset arrayAppend(matchArray,matchup) />
</cfloop>
<!--- LETS SEE OUR LIVE SCORES!!!! --->
<cfif ShowGameDump EQ true>
<cfdump var="#matchArray#" />
</cfif>
<!--- Ok lets do something with our live scores, loop through the array and add total score --->
<!--- This will be our new array to hold our information --->
<cfset matchInfoArray = arrayNew(1)>
<cfloop from="1" to="#arraylen(matchArray)#" index="i">
<cfset matchupinfo = structNew() />
<!--- Set MATCHDATE --->
<cfset matchupinfo.matchdate = matchArray[i].matchdate>
<!--- Set TOTAL POINTS --->
<cfif isnumeric(matchArray[i].teamonescore) AND isnumeric(matchArray[i].teamtwoscore)>
<cfset matchupinfo.total = (matchArray[i].teamonescore + matchArray[i].teamtwoscore)>
<cfelse>
<cfset matchupinfo.total = 0>
</cfif>
<!--- Set TEAM ONE --->
<cfset matchupinfo.teamOne = matchArray[i].teamOne />
<!--- Set TEAM ONE SCORE --->
<cfset matchupinfo.teamOneScore = matchArray[i].teamonescore />
<!--- Set TEAM TWO --->
<cfset matchupinfo.teamTwo = matchArray[i].teamTwo />
<!--- Set TEAM ONE SCORE --->
<cfset matchupinfo.teamTwoScore = matchArray[i].teamtwoscore />
<!--- Add game info to the array --->
<cfset arrayAppend(matchInfoArray,matchupinfo) />
</cfloop>
<cfif ShowPassFail EQ true>
<font size="2" style="color:green;">Live Scoring Template Updated Successfully </font><br /><br /><br /><br />
</cfif>
<cfset variables.UpdatePassed = true>
<cfcatch type="any">
<!--- If something went wrong, lets let display an error message and dump the catch --->
<cfif ShowPassFail EQ true>
<font size="2" style="color:red;">Live Scoring Template Failed to Update </font><br />
</cfif>
<cfset variables.UpdatePassed = false>
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>
<!--- Lets make the display a little nicer :) --->
<table width="100%" border="1">
<tr align="center">
<td>
Team 1
</td>
<td>
Game Info
</td>
<td>
Team 2
</td>
</tr>
<cfloop from="1" to="#arraylen(matchInfoArray)#" index="i">
<cfoutput>
<tr>
<td width="40%" align="left">
<table border="0" width="100%">
<tr>
<td align="center" width="60%">
<font size="4">
#matchInfoArray[i].teamOne#
</font>
</td>
<td align="right">
<font size="6">
#matchInfoArray[i].teamOneScore#
</font>
</td>
</tr>
</table>
</td>
<td width="20%" align="center">
Total: #matchInfoArray[i].total#<br />
#matchInfoArray[i].matchDate#
</td>
<td width="40%">
<table border="0" width="100%">
<tr>
<td align="left">
<font size="6">
#matchInfoArray[i].teamTwoScore#
</font>
</td>
<td align="center" width="60%">
<font size="4">
#matchInfoArray[i].teamTwo#
</font>
</td>
</tr>
</table>
</td>
</tr>
</cfoutput>
</cfloop>
</table>
?Can anyone explain what type of content this feed is?
And is it possible to extract this content into nodes?
If so will the code above be useful?
Comments
You might want to post the
You might want to post the link to the feed, it may be useful
For my example I use this feed
http://sports.espn.go.com/nba/bottomline/scores
What is the deal with this
What is the deal with this data Im using it for an application that I want to make and Im not sure if Im allowed to actually use it. Im hoping to be able to sell this application to other people. Know anywhere where i can get some info on this?
Please do not hijack threads
Please do not hijack threads on other topics.
As for you question, when you repost as a new topic, you might want to mention what this has to do with Drupal.
This is the only person I
This is the only person I have found using this link on the internet to get sports data. I cant find any other info on it.
Have a look at parse_str().
Have a look at parse_str(). This will put the data into an array that you can work with. I don't really understand what the data is. It looks like some kind of results table? I'm sure you could extract the bits you want and loop through it to output a table in HTML.