Code Monkey home page Code Monkey logo

openstates's Introduction

The Open States Project collects and makes available data about state legislative activities, including bill summaries, votes, sponsorships and state legislator information. This data is gathered directly from the states and made available in a common format for interested developers, through a JSON API and data dumps.

Links

Getting Started

We use Docker to provide a reproducible development environment. Make sure you have Docker installed. Inside of the directory you cloned this project into:

docker-compose run --rm scrape <abbreviated state code>  # Scrapes the state indicated by the code e.g. "ny"

For each state, you can also select one or more individual scrapers to run. The scraper names vary from state to state; look at the scrapers listed in the state's __init__.py. For example, Tennessee has:

scrapers = {
    'bills': TNBillScraper,
    'committees': TNCommitteeScraper,
    'events': TNEventScraper,
    'people': TNPersonScraper,
}

So you can limit the scrape to Tennessee's (tn) committees and legislators using:

docker-compose run --rm scrape tn committees people

After retrieving everything from the state, scrape imports the data into a Postgresql database. If you want to skip this step, include a --scrape modifier at the end of the command line, like so:

docker-compose run --rm scrape tn people --scrape

To import data into a postgres database, start the postgres service using docker compose:

docker-compose up postgres

Then run database migrations and import jurisdictions:

docker-compose run --rm dbinit

Now you can run the scrape service without the --scrape flag, and data will be imported into postgres. You can connect to the database and inspect data using psql (credentials are set in docker-compose.yml):

psql postgres://postgres:secret@localhost:5432/openstates

After you run scrape, it will leave .json files, one for each entity scraped, in the _data project subdirectory. These contain the transformed, scraped data, and are very useful for debugging.

Check out the writing scrapers guide to understand how the scrapers work & how to contribute.

Testing

To run all tests:

docker-compose run --rm --entrypoint=nosetests scrape /srv/openstates-web/openstates

Note that Illinois is the only state with scraper tests right now.

Our scraping framework, Pupa, has a strong test harness, and requires well-structured data when ingesting. Furthermore, Open States scrapers should be written to fail when they encounter unexpected data, rather than guessing at its format and possibly ingesting bad data. Together, this means that there aren't many benefits to writing unit tests for particular Open States scrapers, versus relatively high upkeep costs.

API Keys

A few states require credentials to access their APIs. If you want to run code for these states, get credentials for yourself using these steps:

openstates's People

Contributors

jamesturk avatar mikejs avatar twneale avatar mileswwatkins avatar showerst avatar paultag avatar rshorey avatar jmcarp avatar hiteshgarg14 avatar brandonlewis avatar in-vincible avatar schneidy avatar divergentdave avatar mattgrayson avatar tamilyn avatar shivansh-bajaj avatar linzjax avatar estaub avatar markolson avatar cweber avatar mshenfield avatar cliftonmcintosh avatar joegermuska avatar giantryansaul avatar samtregar avatar fgregg avatar rsimoes avatar jballanc avatar csnardi avatar scichelli avatar

Stargazers

Keyth M Citizen  avatar Chris Boston avatar

Watchers

 avatar James Cloos avatar Donny avatar  avatar Tiana Epps-Johnson avatar Jenna Colazzi avatar Whitney May avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.