Screen Shot 2019-07-30 at 8.33.20 PM.png

Senator Search

Senator Search

Background

The year is 2018. It’s April, and it’s cold outside. Why do we care? Because it’s gubernatorial election time! There are 33 out of 100 seats up for grabs in the United States Senate, and it is PRIME TIME for senators campaigning. Unfortunately for them, voters never get as excited for these voting sessions as they do for the more widely broadcast and often more glamorous presidential elections. I wanted to create a way for people to be able to look up information about the senators from their state, so they could learn about who currently represents them and whose seats are up for grabs.

Code Overview

This code written in Python and works by crawling through webpages that are linked together and scraping information in the form of HTML from those pages. Beautiful Soup is then used to parse that HTML and gather the information, and it is cached and stored in a MySQL database. When a user makes a request in the program, the information is then retrieved from those tables using SQL commands. Because the information on the senators is now old, I have commented out the section where it creates a new table of updated senators, and the tables will remain intact for the purpose of preserving the senate of the time. All visualization are generated using plotly.

Sources Used

No APIs were harmed (or used at all) in the making of this project. I scraped all the information you see by way of crawling from the three websites listed below:

https://www.senate.gov/senators/index.htm

https://www.senate.gov/senators/ListofWomenSenators.htm

https://www.senate.gov/senators/EthnicDiversityintheSenate.htm

User Guide

As of now, there is no web interface for this project, it runs purely on your terminal, so in order to use, the code will have to be downloaded.

Once the program loads, it will ask for input, and if you type “help”, all of your option will appear, along with a description of what they do. You will have the option to look up senators by state to see information about them like party, race, and sex. You can also open any senator’s contact page to find out how to directly contact them.

Outside of getting this information on the senators, I wanted people to be able to visualize the makeup of the current senate, and so I created some visualizations on the breakdowns of party, race, and sex within the senate. And, just for fun, every once in a while you might stumble upon a fun fact about a senator or a state in your searches (try looking up California’s Kamala Harris for an example!).

My Code 

The code for this project can be found here.

Enjoy!