Package: oscn
OSCN utilitiesA python library for scraping case information from theOklahoma State Courts Network.Contentsoscn > Python package source to provide an api for retrieving and parsing case records.scripts > Python scripts showing use of the oscn packageexample.py: demonstrates use of the request Case and Caselistretrieve-counts.py: saves a list of all counts for a list of counties and yearsfind-counts.py: saves a list of counts passing a test for a list of counties and yearssoup_test.py: a stub for testing parsing attempts using BeautifulSoupparse_test.py: a stub for developing using saved examplesOSCN packageoscncounties: 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 descriptonstype: function to return case type description. Usage:>>> oscn.type("AO")
'CIVIL ADMINISTRATIVE'oscn.requestCase: 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 detailsParty: Returns information on parties available on OSCN.Docket: Returns docket of cases for specific judges and dateoscn.parseParsers accept the html of an OSCN page and return python objects.Case Page Parsersfiled: 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 nameparties: returns a list of dicts with these keys: id, name, typedocket: returns a list of rows in a docketevents: 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 representingissues: returns a list of dicts with issue information. Each issues includes a list of dicts for each partyParty Page Parsersname: 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 addressDocket Page Parserscases: returns a list of case indexestables: returns the html table for each case in the docketoscn.findCaseIndexes: returns an iterator of case indexes (e.g. tulsa-CF-2019-12).UsageCreate a CaseIndexes list using these key word arguments:county: defaults to all,last_name: use this for company or organization namesfirst_name: optionalmiddle_name: optionalfiled_after: More readable than FiledDateLfiled_before: More readable than FiledDateHclosed_after: More readable than ClosedDateLclosed_before: More readable than ClosedDateHNotesThe % wild card is added to all words in name, first and middleDate arguments use MM/DD/YYY strings.OSCN search parametersIf 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 citationUsing this will override init keyword values such as first or filed_after.Development InstallCreate and activate a Python 3.6 virtual envgit clone git@github.com:codefortulsa/oscn.gitcd oscnpip install -e .UsageInstall withpip install oscnScript example:import oscnRequest 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 scriptspytest tests/or with ipdb:- `pytest -s tests/`specify a test:pytest -s tests/test_parse.py -k 'test_events'Deployment stepspython3 setup.py sdist bdist_wheeltwine upload dist/*User AgentIn some cases a custom user agent is required in the header of requests.
Setting an environmental varialbe called OSCN_USER_AGENT will override the default.