Giter VIP home page Giter VIP logo

legistar-scrape's Introduction

Legistar Scraper is a python library for scraping Legistar sites -- legislation management sites hosted by by Granicus.

Legistar sites include

This software is under active development. It is currently known to work for Chicago and Philadelphia.

Build Status

Installation

> pip install -r requirements.txt
> python setup.py install 

Note: The current stable branch of mechanize has a bug in it. If you are installing the dependencies by hand, use https://github.com/abielr/mechanize.

Tests

To run all unit tests:

nosetests

To run a single test:

nosetests tests/test_legistar_scraper.py:name_of_test

For example, if you wanted to test just the council members pagination

nosetests tests/test_legistar_scraper.py:paging_through_council_members

Example usage

Sample script

from legistar.scraper import LegistarScraper
from legistar.config import Config, DEFAULT_CONFIG

#__________________________________________________________________________
#
# Configure and create a scraper

config = Config(
  hostname = 'chicago.legistar.com',
).defaults(DEFAULT_CONFIG)
scraper = LegistarScraper(config)

#__________________________________________________________________________
#
# Get a summary listing of all of the legislation

all_legislation = scraper.searchLegislation('')

#__________________________________________________________________________
#
# Get more detail for a particular piece of legislation

for legislation_summary in all_legislation:
  (legislation_attrs, legislation_history) = \
    scraper.expandLegislationSummary(legislation_summary)
  break
# NOTE: searchLegislation returns an iterator; you may not use subscript
# indexing (e.g., all_legislation[0]). You may, however, achieve the same
# thing with all_legislation.next()

#__________________________________________________________________________
#
# Get details about legislation history, such as voting results

for history_summary in legislation_history:
  (history_detail, votes) = scraper.expandHistorySummary(history_summary)

#__________________________________________________________________________
#
# Get a list of all council members


councilmembers = scraper.councilMembers()

#__________________________________________________________________________
#
# Get a list of all upcoming agendas

councilmembers = scraper.councilCalendar()

#__________________________________________________________________________
#
# Get a list of all agendas (including past ones)

councilmembers = scraper.councilCalendar('all')

legistar-scrape's People

Contributors

fgregg avatar mjumbewu avatar derekeder avatar guelo avatar

Watchers

James Cloos avatar  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.