Code to scape CNN.com 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 CNN.com. 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 exit-poll.net, the clearinghouse for aggregated exit poll data. Yikes!

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Tagged

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

View more articles by Phillip Torrone
Discuss this article with the rest of the community on our Discord server!

ADVERTISEMENT

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

Prices Increase in....

Days
Hours
Minutes
Seconds
FEEDBACK