Here are some details about my bot.
- I'm getting my data from www.espn.com.
- I work for Wolfram Research, the makers of Mathematica, so that is the software that I use.
- I have some code in Mathematica that I start each day before the game. Here is what the code does:
a. Look up the schedule for the day on ESPN, and figure out the URL that will be used for the pitch-by-pitch play-by-play.
b. 30 minutes before game time, it downloads the initial box.
c. Check philliesphans.com to see if there is a GDT topic about that days game. If there is, it records the topic number for later use. Otherwise, it creates a GDT topic, and uploads a lineup.
d. At game time, it starts polling the pitch-by-pitch URL to see if an event worth reporting has occurred (this step is hard). If it has, it uploads a post to the GDT topic. If the event was the last out of an inning, it will generate a linescore, and upload it. If the event was the last out of the game, it will terminate the code.
The interaction with the web sites, both ESPN and PhilliesPhans is done using HTTP GET, POST and PUT methods. I have been graciously given an API key for PhilliesPhans so that I can use HTTP with the POST and PUT methods.
Those are the basics. The hard part is downloading information from ESPN as XML, and then trying to figure out what the XML means.
Some of the bot issues you might see:
- ESPN gets all messed up, and so my code to interpret the XML produces messed up results.
- My computer loses power (it is a laptop, and might not be connected to power).
- My code has a bug that causes it to crash. When this happens, I have to restart the bot. I have an idea what the issue might be, but it is hard to diagnose.
Some things in the future I might do:
Set up something so that I can remotely stop/restart the bot. Right now I have to have access to my computer to start and restart the bot. This is useful when the bot goes wrong but doesn't crash, or when the bot crashes, and I'm not home with the computer.
Use a Raspberry Pi as a server, so that the bot can live there. My son just got one, and I might take advantage of it. Then I won't have to worry about my computer losing power.
Set up something so that the bot automatically gets restarted when it crashes.
Use a different web site to get results. I have plans to try using mlb.com, because I like that it returns JSON instead of XML, and it also has lots more data (HR distance, pitch type, pitch speed, etc.).
Make my code more robust.
Hope all of that was interesting!