├── .gitignore ├── LICENSE.txt ├── README.md ├── examples ├── case.html ├── count_without_table.html ├── multi_case_table.html ├── multi_count.html ├── no_counts.html └── number_not_used.html ├── oscn ├── __init__.py ├── _meta.py ├── find │ ├── __init__.py │ ├── parse.py │ └── searches.py ├── parse │ ├── __init__.py │ ├── _helpers.py │ ├── bs4_attorneys.py │ ├── bs4_cmids.py │ ├── bs4_counts.py │ ├── bs4_docket.py │ ├── bs4_events.py │ ├── bs4_issues.py │ ├── dates.py │ ├── docket_report.py │ ├── judge.py │ ├── lax_attorneys.py │ ├── lax_body.py │ ├── lax_cmids.py │ ├── lax_counts.py │ ├── lax_docket.py │ ├── lax_events.py │ ├── lax_issues.py │ ├── lax_parties.py │ ├── parties.py │ ├── party_addresses.py │ ├── party_profile.py │ ├── party_properties.py │ └── style.py ├── request │ ├── __init__.py │ ├── cases.py │ ├── docket.py │ └── parties.py ├── requirements.txt └── settings.py ├── requirements.txt ├── scripts ├── docket_test.py ├── events.py ├── example.py ├── find-attorneys.py ├── find-counts.py ├── find_party.py ├── parse_test.py ├── save-counts.py ├── save_cases.py ├── soup_test.py └── test_lists.py ├── setup.py └── tests ├── test_alpha_casenumber.py ├── test_alphacases.py ├── test_appellate.py ├── test_attorneys.py ├── test_body.py ├── test_caselist.py ├── test_cmids.py ├── test_counts.py ├── test_dates.py ├── test_events.py ├── test_find.py ├── test_get_party.py ├── test_issues.py ├── test_judge_docket.py ├── test_lax_docket.py ├── test_lax_events.py ├── test_lax_issues.py ├── test_meta_types.py ├── test_parse.py ├── test_parties.py ├── test_party_search.py ├── test_request.py ├── test_source.py └── test_style.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .env 3 | *.pyc 4 | __pycache__/ 5 | data/ 6 | /*.egg-info 7 | /dist 8 | /build 9 | /examples -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The Python Packaging Authority (PyPA) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OSCN utilities 2 | 3 | A python library for scraping case information from the [Oklahoma State Courts Network](https://www.oscn.net/dockets/). 4 | 5 | # Update: 6 | 7 | - 12/16/2024: Updated to use Selectolax instead of BeautifulSoup. Most parsing functions now use Selectolax which is faster and more memory efficient. Some BeautifulSoup functions are still used and old parsers are still in the codebase for testing. 8 | 9 | ## Contents 10 | 11 | oscn > Python package source to provide an api for retrieving and parsing case records. 12 | 13 | scripts > Python scripts showing use of the oscn package 14 | 15 | - example.py: demonstrates use of the request Case and Caselist 16 | - retrieve-counts.py: saves a list of all counts for a list of counties and years 17 | - find-counts.py: saves a list of counts passing a test for a list of counties and years 18 | - soup_test.py: a stub for testing parsing attempts using BeautifulSoup 19 | - parse_test.py: a stub for developing using saved examples 20 | 21 | ## OSCN package 22 | 23 | ### oscn 24 | 25 | - counties: Returns a list of counties. 26 | - courts: Same as counties but more a accurate description. 27 | - judges: Returns a list of objects formated as {'name': 'Bond, James', 'number': '007'} 28 | - types: returns a dict of case type codes and descriptons 29 | - type: function to return case type description. Usage: 30 | ``` 31 | >>> oscn.type("AO") 32 | 'CIVIL ADMINISTRATIVE' 33 | ``` 34 | 35 | ### oscn.request 36 | 37 | - Case: Returns a single case. Case can be saved as files using Case.save() and retrieved using Case.open(). 38 | 39 | - CaseList: Returns an iterator for retrieving cases for a county and year. CaseLists can be filtered using .find(). See scripts/example.py for details 40 | 41 | - Party: Returns information on parties available on OSCN. 42 | 43 | - Docket: Returns docket of cases for specific judges and date 44 | 45 | ### oscn.parse 46 | 47 | Parsers accept the html of an OSCN page and return python objects. 48 | 49 | #### Case Page Parsers 50 | 51 | - filed: returns a string of the filing date (e.g. 12/25/2017) 52 | - closed: returns a string of the date the case was closed. Return None if not closed. 53 | - counts: returns of list of count dicts found in a case. Keys include 'description' 54 | of the count. If available 'violation' and 'disposed' are added. 55 | - judge: returns a string of the judge's name 56 | - parties: returns a list of dicts with these keys: id, name, type 57 | - docket: returns a list of rows in a docket 58 | - 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. 59 | - attorneys: returns a list of dicts with these keys: name, address, and representing 60 | - issues: returns a list of dicts with issue information. Each issues includes a list of dicts for each party 61 | 62 | #### Party Page Parsers 63 | 64 | - name: returns 'Requested Party' 65 | - alias: returns 'Alias or Alternate Names' 66 | - profile: returns dict of values in 'Personal Profile' 67 | - birth_month: returns string of 'Birth Month and Year' 68 | - addresses: returns a list of dicts for each address 69 | 70 | #### Docket Page Parsers 71 | 72 | - cases: returns a list of case indexes 73 | - tables: returns the html table for each case in the docket 74 | 75 | ### oscn.find 76 | 77 | - CaseIndexes: returns an iterator of case indexes (e.g. tulsa-CF-2019-12). 78 | 79 | #### Usage 80 | 81 | Create a CaseIndexes list using these key word arguments: 82 | 83 | - county: defaults to all, 84 | - last_name: use this for company or organization names 85 | - first_name: optional 86 | - middle_name: optional 87 | - filed_after: More readable than FiledDateL 88 | - filed_before: More readable than FiledDateH 89 | - closed_after: More readable than ClosedDateL 90 | - closed_before: More readable than ClosedDateH 91 | 92 | #### Notes 93 | 94 | - The % wild card is added to all words in name, first and middle 95 | - Date arguments use MM/DD/YYY strings. 96 | 97 | #### OSCN search parameters 98 | 99 | 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 100 | 101 | Using this will override init keyword values such as first or filed_after. 102 | 103 | ## Development Install 104 | 105 | 1. python3 -m venv ~/your_path/oscn 106 | 1. source ~/your_path/oscn/bin/activate 107 | 1. `git clone git@github.com:codefortulsa/oscn.git` 108 | 1. `cd oscn` 109 | 1. `pip install -e .` 110 | 111 | ## Usage 112 | 113 | Install with `pip install oscn` 114 | 115 | Script example: 116 | 117 | `import oscn` 118 | 119 | Request a single case: 120 | 121 | `oscn.request.Case(county='tulsa', year='2018', number=84)` 122 | 123 | or use case index notation: 124 | 125 | `oscn.request.Case('love-CF-2019-25')` 126 | 127 | To request a list of cases to iterate: 128 | 129 | `oscn.request.CaseList(county='adair', year='2016')` 130 | 131 | ## Run test scripts 132 | 133 | - `pytest tests/` 134 | 135 | or with ipdb: 136 | 137 | - `pytest -s tests/` 138 | 139 | specify a test: 140 | 141 | - `pytest -s tests/test_parse.py -k 'test_events'` 142 | 143 | ## Deployment steps 144 | 145 | 1. Edit setup.py 146 | 1. `python3 setup.py sdist bdist_wheel` 147 | 1. `twine upload dist/*` 148 | 149 | ## User Agent 150 | 151 | In some cases a custom user agent is required in the header of requests. 152 | Setting an environmental varialbe called OSCN_USER_AGENT will override the default. 153 | -------------------------------------------------------------------------------- /examples/count_without_table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 |The information on this page is NOT an official 297 | record. Do not rely on the correctness or completeness of this 298 | information. Verify all information with the official record 300 | keeper. The information contained in this report is provided in 301 | compliance with the Oklahoma Open Records Act, 302 | 51 O.S. 24A.1. 303 | Use of this information is governed by this act, as well as other 304 | applicable state and federal laws. 305 |
306 |STATE OF OKLAHOMA, 311 | Plaintiff, 312 | v. 313 | SABRINA NICOLE WILSON, 314 | Defendant. |
315 |
316 | No. CF-2018-14 317 | (Criminal Felony) 318 | 319 | Filed: 01/02/2018 Closed: 03/28/2018 Judge: CF B Docket |
320 |
STATE OF OKLAHOMA,
324 | Plaintiff
Tulsa County Sheriff's Department,
325 | ARRESTING AGENCY
WILSON, SABRINA NICOLE,
326 | Defendant
327 |
Attorney | 333 |Represented Parties | 334 |
---|---|
TULSA COUNTY PUBLIC DEFENDER 339 | |
340 | WILSON, SABRINA NICOLE |
341 |
Event | 349 |Party | 350 |Docket | 351 |Reporter | 352 |
---|---|---|---|
357 | Wednesday, January 17, 2018 at 9:01 AM PRELIMINARY HEARING NO ISSUE (PUBLIC DEFENDER) |
360 | WILSON, SABRINA NICOLE | 361 |Preliminary Hearing Docket | 362 |363 | | 364 |
367 | Wednesday, February 7, 2018 at 9:01 AM PRELIMINARY HEARING STC OF CIVIL COMM (PUBLIC DEFENDER) |
370 | WILSON, SABRINA NICOLE | 371 |Preliminary Hearing Docket | 372 |373 | | 374 |
377 | Wednesday, March 21, 2018 at 9:01 AM PRELIMINARY HEARING NO ISSUE/REVIEW OF CIVIL COMMIT PROGRAM |
380 | WILSON, SABRINA NICOLE | 381 |Preliminary Hearing Docket | 382 |383 | | 384 |
387 | Wednesday, March 28, 2018 at 9:01 AM PRELIMINARY HEARING REVIEW OF CIVIL COMMIT (PUBLIC DEFENDER) |
390 | WILSON, SABRINA NICOLE | 391 |Preliminary Hearing Docket | 392 |393 | | 394 |
399 | Parties appear only under the counts with which they were charged. For complete sentence information, see the court minute on the docket.
Count # 1. | 404 |
405 | Count as Filed:
406 | ABOFF, ASSAULT & BATTERY UPON A DETENTION OFFICER,
407 | in violation of 21 O.S. 649 B Date of Offense: 12/28/2017 |
408 |
414 | | Party Name | 415 |Disposition Information | 416 |
---|---|---|
421 | |
423 |
424 | Disposed: DISMISSED,
425 | 03/28/2018.
426 | Dismissed- Request of the State 427 | Count as Disposed: ASSAULT & BATTERY UPON A DETENTION OFFICER(ABOFF) 428 | Violation of 429 | 21 O.S. 649 B |
430 |
Count # 2. | 438 |
439 | Count as Filed:
440 | ABOFF, ASSAULT & BATTERY UPON A DETENTION OFFICETR,
441 | in violation of 21 O.S. 649 B Date of Offense: 12/28/2017 |
442 |
448 | | Party Name | 449 |Disposition Information | 450 |
---|---|---|
455 | |
457 |
458 | Disposed: DISMISSED,
459 | 03/28/2018.
460 | Dismissed- Request of the State 461 | Count as Disposed: ASSAULT & BATTERY UPON A DETENTION OFFICETR(ABOFF) 462 | Violation of 463 | 21 O.S. 649 B |
464 |
Date | 473 |Code | 474 |Description | 475 |Count | 476 |Party | 477 |Amount | 478 |
---|---|---|---|---|---|
483 | |
485 |
486 | |
488 |
489 | 490 | CRIMINAL FELONY INITIAL FILING. 491 | 492 |Document Available at Court Clerk's Office 493 | |
494 | 1 495 | | 496 |WILSON, SABRINA NICOLE | 497 |498 | |
501 | |
503 |
504 | |
506 |
507 | 508 | DEFENDANT SABRINA NICOLE WILSON WAS CHARGED WITH COUNT #1, ASSAULT & BATTERY UPON A DETENTION OFFICER IN VIOLATION OF 21 O.S. 649 B 509 | 510 | |
511 | 1 512 | | 513 |WILSON, SABRINA NICOLE | 514 |515 | |
518 | |
520 |
521 | |
523 |
524 | 525 | DEFENDANT SABRINA NICOLE WILSON WAS CHARGED WITH COUNT #2, ASSAULT & BATTERY UPON A DETENTION OFFICETR IN VIOLATION OF 21 O.S. 649 B 526 | 527 | |
528 | 2 529 | | 530 |WILSON, SABRINA NICOLE | 531 |532 | |
535 | |
537 |
538 | |
540 |
541 | 542 | OCIS HAS AUTOMATICALLY ASSIGNED JUDGE CF D DOCKET TO THIS CASE. 543 | 544 | |
545 | 546 | | 547 | | 548 | |
551 | |
553 |
554 | |
556 |
557 |
558 | JUDGE DAWN MOODY: CASE REASSIGNED TO CF: B BASED ON CF-17-6443. |
561 | 562 | | WILSON, SABRINA NICOLE | 563 |564 | |
567 | |
569 |
570 | |
572 |
573 | 574 | JUDGE DAWN MOODY: DEFENDANT PRESENT, IN CUSTODY AND PUBLIC DEFENDER APPOINTED AS COUNSEL OF RECORD. ARRAIGNMENT HELD. DEFENDANT WAIVES READING OF THE INFORMATION AND FURTHER TIME TO PLEAD. DEFENDANT ENTERS A PLEA OF NOT GUILTY. PRELIMINARY HEARING NO ISSUE SET FOR 1/17/18 @ 9AM IN ROOM 347. BOND $10,000.00 AGG BOND. DEFENDANT REMANDED TO CUSTODY. 575 | 576 | |
577 | 578 | | WILSON, SABRINA NICOLE | 579 |580 | |
583 | |
585 |
586 | |
588 |
589 | 590 | DISTRICT ATTORNEY INSPECTION NOTIFICATION 591 | 592 |
593 | Document Available (#1039099589)
594 | |
598 | 599 | | WILSON, SABRINA NICOLE | 600 |601 | |
604 | |
606 |
607 | |
609 |
610 | 611 | TULSA COUNTY PUBLIC DEFENDER'S OFFICE INSPECTION REQUEST 612 | 613 |
614 | Document Available (#1039096460)
615 | |
619 | 620 | | WILSON, SABRINA NICOLE | 621 |622 | |
625 | |
627 |
628 | |
630 |
631 | 632 | PAUPER'S AFFIDAVIT 633 | 634 |
635 | Document Available (#1039096611)
636 | |
640 | 641 | | WILSON, SABRINA NICOLE | 642 |643 | |
646 | |
648 |
649 | |
651 |
652 | 653 | RETURN COMMITMENT 654 | 655 |
656 | Document Available (#1039100255)
657 | |
661 | 662 | | WILSON, SABRINA NICOLE | 663 |664 | |
667 | |
669 |
670 | |
672 |
673 | 674 | ORDER FOR REASSIGNMENT OF CRIMINAL DISTRICT JUDGE 675 | 676 |
677 | Document Available (#1039210514)
678 | |
682 | 683 | | WILSON, SABRINA NICOLE | 684 |685 | |
688 | |
690 |
691 | |
693 |
694 | 695 | AFFIDAVIT & FINDING OF PROBABLE CAUSE T.R.A.C.I.S. (ARRESTED) 696 | 697 |Document Available at Court Clerk's Office 698 | |
699 | 700 | | WILSON, SABRINA NICOLE | 701 |702 | |
705 | |
707 |
708 | |
710 |
711 | 712 | JUDGE JAMES KEELEY: DEFENDANT PRESENT, IN CUSTODY AND REPRESENTED BY KASEY BALDWIN. STATE REPRESENTED BY SEAN WATERS. PRELIMINARY HEARING PASSED FOR STATUS OF CIVIL COMMITMENT TO 2/28/18 AT 9:00 AM ROOM 347. BOND TO REMAIN; DEFENDANT REMANDED TO CUSTODY. 713 | 714 | |
715 | 716 | | WILSON, SABRINA NICOLE | 717 |718 | |
721 | |
723 |
724 | |
726 |
727 | 728 | ACKNOWLEDGEMENT OF RECEIPT OF DISCOVERY 729 | 730 |
731 | Document Available (#1039206463)
732 | |
736 | 737 | | 738 | | 739 | |
742 | |
744 |
745 | |
747 |
748 | 749 | JUDGE JAMES KEELEY: COURT RESETS STATUS OF CIVIL COMMITMENT TO 2/7/18 AT 9:00 AM ROOM 347 750 | 751 | |
752 | 753 | | WILSON, SABRINA NICOLE | 754 |755 | |
758 | |
760 |
761 | |
763 |
764 | 765 | JUDGE JAMES KEELEY: DEFENDANT PRESENT, IN CUSTODY, AND REPRESENTED BY KASEY BALDWIN PD. STATE REPRESENTED BY SEAN WATERS. PRELIMINARY HEARING/REVIEW PASSED TO 3-21-2018 @ 9 AM IN ROOM 347. PR BOND AUTHORIZED, RELEASE ISSUED, DEFENDANT APPEARANCE IS WAIVED AT NEXT COURT DATE IF DEFENDANT IS INCOMPLIANT WITH CIVIL COMMIT PROGRAM. . 766 | 767 | |
768 | 769 | | WILSON, SABRINA NICOLE | 770 |771 | |
774 | |
776 |
777 | |
779 |
780 | 781 | RECOGNIZANCE BOND FOR WILSON, SABRINA NICOLE POSTED BY WILSON, SABRINA NICOLE, POSTED 02/08/2018 782 | 783 |
784 | Document Available (#1039453123)
785 | |
789 | 790 | | WILSON, SABRINA NICOLE | 791 |792 | $ 35.00 793 | | 794 |
797 | |
799 |
800 | |
802 |
803 | 804 | RETURN RELEASE 805 | 806 |
807 | Document Available (#1039525166)
808 | |
812 | 813 | | WILSON, SABRINA NICOLE | 814 |815 | |
818 | |
820 |
821 | |
823 |
824 |
825 | JUDGE JAMES KEELEY: DEFENDANT NOT PRESENT, BENCH WARRANT UNDER ADVISEMENT, AND REPRESENTED BY KASEY BALDWIN. STATE REPRESENTED BY MARY KNOPP. PRELIMINARY HEARING/REVIEW PASSED TO 3-28-2018 @ 9 AM IN ROOM 347. DEFENDANT'S APPEARANCE IS WAIVED AT NEXT COURT DATE IF DEFENDANT IS INCOMPLIANT WITH CIVIL COMMIT PROGRAM. |
828 | 829 | | WILSON, SABRINA NICOLE | 830 |831 | |
834 | |
836 |
837 | |
839 |
840 |
841 | JUDGE JAMES KEELEY: DEFENDANT PRESENT, NOT IN CUSTODY AND REPRESENTED BY PUBLIC DEFENDER. STATE REPRESENTED BY MARY KNOPP. DSMISSED BY COURT, AT REQUEST OF STATE, COST TO STATE. BOND EXONERATED. |
844 | 1 845 | | 846 |WILSON, SABRINA NICOLE | 847 |848 | |
Case Number | 248 |Date Filed | 249 |Style | 250 |Date Closed | 251 |
---|---|---|---|
CF-2018-00020A | 256 |01/12/2018 | 257 |STATE OF OKLAHOMA V. COLTON WAYNE GIBSON | 258 |259 | | 260 |
CF-2018-00020B | 263 |01/12/2018 | 264 |STATE OF OKLAHOMA V. JUSTIN GIBSON | 265 |266 | | 267 |
The information on this page is NOT an official 297 | record. Do not rely on the correctness or completeness of this 298 | information. Verify all information with the official record 300 | keeper. The information contained in this report is provided in 301 | compliance with the Oklahoma Open Records Act, 302 | 51 O.S. 24A.1. 303 | Use of this information is governed by this act, as well as other 304 | applicable state and federal laws. 305 |
306 |THIS CASE NUMBER WAS NOT USED | 311 |
312 | No. CF-2017-122 313 | (Criminal Felony) 314 | 315 | Filed: Judge: Unassigned |
316 |
None 320 |
321 | None
325 | None
328 | Parties appear only under the counts with which they were charged. For complete sentence information, see the court minute on the docket.