Skip to main content

Oklahoma State Courts Network case parsing utilities

Project description

OSCN utilities

A python library for scraping case information from the Oklahoma State Courts Network.

Contents

oscn > Python package source to provide an api for retrieving and parsing case records.

scripts > Python scripts showing use of the oscn package

  • example.py: demonstrates use of the request Case and Caselist
  • retrieve-counts.py: saves a list of all counts for a list of counties and years
  • find-counts.py: saves a list of counts passing a test for a list of counties and years
  • soup_test.py: a stub for testing parsing attempts using BeautifulSoup
  • parse_test.py: a stub for developing using saved examples

OSCN package

oscn

  • counties: Returns a list of counties.
  • courts: Same as counties but more a accurate description.
  • judges: Returns a list of objects formated as {'name': 'Bond, James', 'number': '007'}
  • types: returns a dict of case type codes and descriptons
  • type: function to return case type description. Usage:
    >>> oscn.type("AO")
    'CIVIL ADMINISTRATIVE'
    

oscn.request

  • Case: Returns a single case. Case can be saved as files using Case.save() and retrieved using Case.open().

  • CaseList: Returns an iterator for retrieving cases for a county and year. CaseLists can be filtered using .find(). See scripts/example.py for details

  • Party: Returns information on parties available on OSCN.

  • Docket: Returns docket of cases for specific judges and date

oscn.parse

Parsers accept the html of an OSCN page and return python objects.

Case Page Parsers

  • filed: returns a string of the filing date (e.g. 12/25/2017)
  • closed: returns a string of the date the case was closed. Return None if not closed.
  • counts: returns of list of count dicts found in a case. Keys include 'description' of the count. If available 'violation' and 'disposed' are added.
  • judge: returns a string of the judge's name
  • parties: returns a list of dicts with these keys: id, name, type
  • docket: returns a list of rows in a docket
  • events: returns a list of dicts with these keys: event, party, docket, reporter, date, description. The keys date and description are cleaner versions of the event text. The event key will be deprecated some day so use date and description if you are starting a project.
  • attorneys: returns a list of dicts with these keys: name, address, and representing
  • issues: returns a list of dicts with issue information. Each issues includes a list of dicts for each party

Party Page Parsers

  • name: returns 'Requested Party'
  • alias: returns 'Alias or Alternate Names'
  • profile: returns dict of values in 'Personal Profile'
  • birth_month: returns string of 'Birth Month and Year'
  • addresses: returns a list of dicts for each address

Docket Page Parsers

  • cases: returns a list of case indexes
  • tables: returns the html table for each case in the docket

oscn.find

  • CaseIndexes: returns an iterator of case indexes (e.g. tulsa-CF-2019-12).

Usage

Create a CaseIndexes list using these key word arguments:

  • county: defaults to all,
  • last_name: use this for company or organization names
  • first_name: optional
  • middle_name: optional
  • filed_after: More readable than FiledDateL
  • filed_before: More readable than FiledDateH
  • closed_after: More readable than ClosedDateL
  • closed_before: More readable than ClosedDateH

Notes

  • The % wild card is added to all words in name, first and middle
  • Date arguments use MM/DD/YYY strings.

OSCN search parameters

If you are familar with the OSCN search parameters you can initialize CaseIndexes using these as key word arguments: db, number, lname, fname, mname, DoBMin, DoBMax, partytype, apct, dcct, FiledDate, FiledDateH, ClosedDateL, ClosedDateH, iLC, iLCType, iYear, iNumber, and citation

Using this will override init keyword values such as first or filed_after.

Development Install

  1. Create and activate a Python 3.6 virtual env
  2. git clone git@github.com:codefortulsa/oscn.git
  3. cd oscn
  4. pip install -e .

Usage

Install with pip install oscn

Script example:

import oscn

Request a single case:

oscn.request.Case(county='tulsa', year='2018', number=84)

or use case index notation:

oscn.request.Case('love-CF-2019-25')

To request a list of cases to iterate:

oscn.request.CaseList(county='adair', year='2016')

Run test scripts

  • pytest tests/

or with ipdb:

- `pytest -s tests/`

specify a test:

  • pytest -s tests/test_parse.py -k 'test_events'

Deployment steps

  1. python3 setup.py sdist bdist_wheel
  2. twine upload dist/*

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oscn-0.0.0.72.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

oscn-0.0.0.72-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file oscn-0.0.0.72.tar.gz.

File metadata

  • Download URL: oscn-0.0.0.72.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for oscn-0.0.0.72.tar.gz
Algorithm Hash digest
SHA256 e05fcc37da411d56454d4bc65bb000e6c5e7219d040902db3063360bad3b0fd3
MD5 612ef3258d1aeefe334dc8aac0bcf800
BLAKE2b-256 24d0eb37f2fdc9c2a8e91979803ad795d1cbd764eff50667cb794b93905b05d0

See more details on using hashes here.

File details

Details for the file oscn-0.0.0.72-py3-none-any.whl.

File metadata

  • Download URL: oscn-0.0.0.72-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for oscn-0.0.0.72-py3-none-any.whl
Algorithm Hash digest
SHA256 ddbb14aa66f8190cefe2cc02135b54e6b478a33df41679ec5e8304cca873e404
MD5 8d109ba97922485f6bc34cabf92775bd
BLAKE2b-256 a4c8a5859bb06a9b78ff02f4df05e0e0c17811d8252af91b0ba376fa8821929b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page