Package: nswcaselaw
nswcaselawA Python toolkit for downloading and extracting textual data from the NSW
CaseLaw website athttps://www.caselaw.nsw.gov.au/UsageSample usage in Python code or a Jupyter notebookfrom nswcaselaw.search import Search
import json

query = Search(courts=[13], catchwords="succession", pause=1)

for decision in query.results():
  decision.fetch()
  print(json.dumps(decision.values, indent=2))

url = query.urlCLI toolTo generate a CSV of search resultsnswcaselaw --courts 13 --catchwords succession --output cases.csvTo download complete decisions as JSON documentsnswcaselaw --courts 13 --catchwords succession --output cases.csv  --download ./decisionsTo list available courts and tribunals (NOTE: full web scraping is only
tested on Supreme Court decisions)nswcaselaw --list courts
nswcaselaw --list tribunalsCommand-line parameters:-h, --help            show help message and exit
--version             show program's version number and exit
-v, --verbose         set loglevel to INFO
-vv, --very-verbose   set loglevel to DEBUG
--list {courts,tribunals}
                      Print a list of courts or tribunals
--dump DUMP           Dir to dump HTML for debugging
--test-parse TEST_PARSE
                      Test scraper on an HTML document and print results as
                      JSON
--body BODY           Full text search
--title TITLE         Case name
--before BEFORE
--catchwords CATCHWORDS
--party PARTY
--citation CITATION   This must include square brackets
--startDate STARTDATE
                      Earliest decision date
--endDate ENDDATE     Lastest decision date
--fileNumber FILENUMBER
--legislationCited LEGISLATIONCITED
--casesCited CASESCITED
--pause PAUSE         Seconds to wait between requests: default 10
--courts COURTS [COURTS ...]
                      Select one or more by index number (see --list courts)
--tribunals TRIBUNALS [TRIBUNALS ...]
                      Select one or more by index number (see --list
                      tribunals)
--uris URIS           CSV file with caselaw URIs to download
--output OUTPUT       Search results will be written to this file as CSV
--download DOWNLOAD   Save decisions as JSON to the directory DOWNLOAD
--limit LIMIT         Max resultsInstallationFollow the instructions athttps://docs.conda.io/projects/conda/en/latest/user-guide/install/download.htmlto install Conda.To create a conda environment with Jupyter and nswcaselawconda create -n mycaselaw jupyter
conda activate mycaselaw
pip install nswcaselawOnce the dependencies are installedjupyter notebookwill start Jupyter and open a browser. Any notebooks you create in this will
be able to import the nswcaselaw module as shown abovefrom nswcaselaw.search import SearchTo install nswcaselaw without Jupyter, follow the same steps to install Conda,
and then create a new environment as followsconda create -n mycaselaw
conda activate mycaselaw
pip install nswcaselawYou should now be able to use thenswcaselawcommand from a terminal (on
Mac or Linux) or the Anaconda prompt (on Windows).AcknowledgementsThis project is partially funded by a 2022 University of Sydney Research
Accelerator (SOAR) Prize awarded to Ben Chen.NoteThis project has been set up using PyScaffold 4.3. For details and usage
information on PyScaffold seehttps://pyscaffold.org/.