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!

Discuss this article with the rest of the community on our Discord server!

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

View more articles by Phillip Torrone
Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).