This repository contains code to retrieve results for the February 2023 Municipal Election.
Already performed the setup? β© Jump to instructions for Running the scraper.
- Python 3. Download and install the latest version of Python here: https://www.python.org/downloads/
- Git. Download and install Git here: https://sourceforge.net/projects/git-osx-installer/
Open a command line. On a Mac, you can use the Terminal
app.
To run a command, type or copy and paste the listed incantation into your command line, then press Enter (or Return).
In the Terminal
app, navigate to your desktop:
cd ~/Desktop
Download the scraper code:
git clone https://github.com/datamade/block-club-election-night.git
Navigate into the directory containing the scraper code:
cd block-club-election-night
Create and activate a virtual environment, then install the scraper:
python3 -m venv ~/.virtualenvs/elections
source ~/.virtualenvs/elections/bin/activate
pip install -r requirements.txt
Whether you want to scrape the summary file or precinct results, you first need to navigate into the directory containing the scraper code and activate your virtual environment. If you just finished setup, above, you can skip this step!
cd ~/Desktop/block-club-election-night
source ~/.virtualenvs/elections/bin/activate
Run the summary file scraper like this:
python3 -m election_night.get_results
You should see something like this in your terminal:
Getting summary results from https://chicagoelections.gov/results/ap/SummaryExport.txt! π
This indicates the scrape ran successfully!
You can view the output in the results/
folder. Output files are grouped in a sub-folder named for the date and time you ran the scrape.
If you'd like to scrape the zero file posted by the Board of Elections for testing, run:
python3 -m election_night.get_results --test
Late on Election Night and into the following day, the Board of Elections stops updating the summary file in favor of precinct-level results. You can run the precinct scraper like this:
python3 -m election_night.get_results --precinct
You should see something like this in your terminal:
Getting precinct results for 2023 Municipal Runoffs - 4/4/23! π
Note that scraping precinct results takes about a minute to run, since the pages are slow to load.
As before, when the scrape completes, you can view the output in the results/
folder. Output files are grouped in a sub-folder named for the date and time you ran the scrape.