|
|||
Main
Dyeing
The Official Wicked Hair Dyeing Page Online Since 1995 Cribbage Board #10
"The Wedding Board"
Projects
Adventures / Interests
blog.redstoyland
photos.redstoyland
|
ioah2ical.pyIce Oasis Adult Hockey Schedules to iCalendarLatest Export March 27, 2008
|
| File Package | ioah2ical_source (includes ioah2ical.py, BeautifulSoup and Readme) |
|
Current Revision |
October 3, 2007 |
|
Written in: |
Python 2.4 (works with 2.5 as well) |
|
Dependencies |
Playing in 2 leages at Ice Oasis would typically mean a lot of manual entry of my game schedule into iCal (or Rainlendar on the PC). Since the Ice Oasis schedules are simply table formatted, they made for a nice project to scrape the html and then push the schedules into an iCalendar (.ics) file.
Created basic iCalendar class and iCalendarEvent class
Sure, I looked at other python implementations for iCalendar, but they all seemed heavy-handed or overly complicated for a simple web-scrape-to-ics-file. These are simple formatting classes. The iCalendar class exists to create the header and then append iCalendarEvent items. In the end, the class outputs .ics files for inclusion into all modern calendaring systems (of which Outlook is not a member). Feel free to port these classes to your own code.
*NEW* Created "zipDir()" function
Believe it or not, I had a tough time finding an example zipDir() function out there. I found some things that sort of did it (sort of), but nothing that really kept the directory structure intact. There are most definitely better ways of doing this. zipDir() is built into ioah2ical.py, but you can get the standalone function: zipDir.py
*NEW* Created basic i2iFrontEnd class
This enables the Autopliot mode. It's basically a storage/globals class for automating the login in process as well as the directory structure creation and whatnot. Expect the globals to need updated every season, as IOAH does not rely on hard coded URLs for schedules.... shucks.
*NEW* Autopilot mode
Autopilot mode asks for your username and password, then handles all the login info, html grabbing and scraping to create all of the iCal schedules for all of the nights. Sweet, huh?
Cheesy interactive mode on the command line
I said it was cheesy! Got python 2.4 and BeautifulSoup 3 installed, you simply gotta type python /path/to/ioah2ical.py from the command line and the program will ask for the saved html file, it's rough format, and where ya' wanna put the ics file. But why bother, I've already done that for all the nights and all the teams!
*Deprecated* What's up with the format options?
Well, there used to be an All Schedules page and a My Schedules page and they were formatted differently, and required different settings to scrape correctly. With recent changes to the IOAH web page, most likely you are viewing the All Schedules page.
Hackery
Yeah, there's some hacking going on (like the way I just copy/paste in the timezone declaration). But then again, for a project that was supposed to save me 1 hour of data-entry time, it took me many hours of coding to complete. So, I took some shortcuts and hacked around a little. I also left lots of comments and hackery exmaples in there as I was figuring things out. It's not cleaned up to say the least. That said, it does work and I plan to continue using this thing---just don't complain about stylistic things, eh?
FUTURE PLANS:
UPDATES: Read the ioah2ical.py file for 'official' update listing.
9-9-2007 Added a super groovy AUTOPILOT mode. Try it out! It logs in for you, grabs all the schedules, saves them to a directory of your choice, then scrapes them and outputs iCalendar files. Super simple.
5-1-2007: Added ability to scrape multiple html files in a batch mode. Save your nights to a directory and send the script headed that way. Also cleaned up the interactive UI mode a little bit.
|
©
March 27, 2008
|