Posts Tagged ‘Scores’
Free NFL Live Scores Feed Using ColdFusion Can be used for NBA, NCAA, NHL, GOLF Scores Feed
Written by wecodethings on December 2, 2009 – 5:38 pm
So once upon a time, I had an idea that it would be cool to run a little personal website that was only to be used by my friends. This website was to have a number of NFL football games that you could pick from and then if you guessed the most right, you win.
Sounds very simple right? WRONG! I ran into a HUGE roadblock. I first built the site so I could input the games that you could pick from manually, then after the games were over, I would have to input the scores manually. Seeing how this gets very annoying, I wanted to incorporate some live scoring.
I tried to find a free xml feed, however, this was not the case. I spent at least a month searching to find a feed that I could use for my site. I thought about html scraping, but that seemed tedious, a lot of work and if their site changed, I would have to change my code. That idea was no good.
So I decided that I would pay for it. I mean how much could a NFL scores feed really cost right? Wow, I couldn’t have been more wrong!
I called Stats.inc and after 2 weeks of me explaining that I wanted the cheapest form of scores and that I was a non-profit website, they gave me a quote of $40,000.
Yes… I said $40,000 to get a feed that will save me 5 minutes inputting my own scores.
So, I decided to not spend the price of a brand new Lexus on 5 minutes of score inputting and continue my search for a free feed.
After a year of occasionally looking, my buddy stumbled upon something that was actually useful.
(He gave me only the direct url, so I don’t know the site or forum where he found it. sorry)
Here is what he found: http://sports.espn.go.com/nfl/bottomline/scores
An ESPN link that has only the output of a url string, which inside of the url string are LIVE SCORES!
My first question was why the hell does ESPN have a link that just produces a url string and nothing else.
So I decided to investigate a little further. I found that if you strip the directories, you get: http://sports.espn.go.com
Which is a desktop application used by ESPN to install a sports ticker on your computer. This application sends http requests to ESPN to update the ticker which is installed on your computer. So if there is a nfl url link, then there must others right?
Right!
I installed the ticker, and then used a packet sniffer to grab all the http requests being sent from my computer. It revealed all of the url strings being used by ESPN to update the ticker.
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
So now I have:
1. Consistency. ESPN uses the url string to update their application, therefore there should be little if no code changes that will be needed after I initially write the code to extract the scores.
2. FREE! I get to spend $40,000 somewhere else.
3. Accurate Scores. Since the feed is coming from ESPN and not a 3rd party site that might go down or put in bad scores, I feel good about this one.
4. Easier project. Parse a url string? Wayyy better than html scraping, or any other horrible method to extract the data.
(I would like to thank Steve Weyrick CFBLOGWORM for working on this project as well)
So for reason 1-4, I wrote this code. ENJOY!
Keep in mind that if you come across this blog while the NFL is in the off season, you will not see the scores on the demo because the scores are live J
Tags: ColdFusion, Feed, Live, NFL, Scores, Scoring
Posted in ColdFusion, HTML | 4 Comments »