Code to scape election results

Computers & Mobile

Eric posted up a cool Python script that he’s plugging in to his lighting system to turn the colors red/blue depending on who is winning… via Hackaday.

My election party tomorrow will feature DMX controlled RGB LED lighting. The color of the house should reflect the electoral balance. The color will start purple, and drift toward either red or blue, depending on who’s winning…

In order to do this, it was necessary to obtain live election results. Presented for your use is a simple python urllib2 scraper which will fetch live results from Return value is ((dpopular, delectoral), (rpopular, relectoral)). Furthermore, when CNN calls the race, the get method throws an ElectionWon exception. This code is in the public domain. The data, however, actually costs around $4000 if you buy it directly from, the clearinghouse for aggregated exit poll data. Yikes!


current: @adafruit - previous: MAKE, popular science, hackaday, engadget, fallon, braincraft ... howtoons, 2600...

View more articles by Phillip Torrone
Send this to a friend