joegratz.net

March 5, 2007

NextBus Python Script

This will be useful to almost nobody, but someone on SFist asked about it, so here it is.

This is a Python CGI which grabs and parses the XML bus prediction data from NextBus.com for the San Francisco Muni. I wrote it so I could have easy mobile access to certain bus lines (including my beloved 21-Hayes) for which data wasn’t otherwise easily accessible. It doesn’t work for that anymore; it only works for bus lines for which the data is easily available on NextBus.com. (Apparently the rest of the bus lines will be available soon.)

Anyway, this is likely to be of some use to people who want to do cool SOAP web services stuff with the Muni bus prediction XML data. Right now it’s a CGI that provides a really light fast web interface for the prediction data, but it could pretty easily be hacked into a command line prediction script or a widget or a much slicker web interface. It’s licensed under CC-BY. Here it is:

NextBus Python Script

1 Comment

  1. yeah! this is cool. getting the session cookie set is the trick to loading the xml…

    the neat part about the XML data is it includes gps coords of all the busses on the route..

    Comment by skot — March 6, 2007 @ 12:02 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Linkblog Atom Feed

Disclaimer Haiku:
West wind seems to say,
"This is not legal advice;
I'm not your lawyer."

(And if you're a client with whom I have a preexisting attorney-client relationship, this still isn't legal advice.)

In case you're wondering, this blog is also not intended as advertising, as a representation of anything but my personal opinion, or as an offer of representation.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License.
[powered by WordPress.]
[generated in 0.351 seconds.]