Giter VIP home page Giter VIP 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 your Open States repository directory, run a scrape for a specific state by running:

docker-compose run --rm scrape <state postal code>

You can also choose to scrape only specific data types for a state. The data types available vary from state to state; look at the scrapers listed in the state's __init__.py for a list. For example, Tennessee (with a state postal code of tn) has:

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

So you can limit a Tennessee scrape to only 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 flag at the end of your command, like so:

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

If you do want to import data into Postgres, start a Postgres service using Docker Compose:

docker-compose up postgres

Then run database migrations and import jurisdictions, thus initializing the database contents:

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 (with or without the Postgres import), it will leave one JSON file in the _data subdirectory for each entity that was scraped. These JSON files contain the transformed, scraped data, and are very useful for debugging.

Check out the writing scrapers guide to understand more about how the scrapers work, and how you can contribute.

Testing

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 high upkeep costs.

Occasionally, states will have unit tests, though, for specific structural cases. To run all tests:

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

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 showerst avatar mileswwatkins avatar paultag avatar rshorey avatar jmcarp avatar hiteshgarg14 avatar brandonlewis avatar in-vincible avatar schneidy avatar divergentdave avatar mattgrayson avatar tamilyn avatar estaub avatar shivansh-bajaj avatar linzjax 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

Watchers

 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.