64 lines
4.3 KiB
Python
64 lines
4.3 KiB
Python
import json, urllib.request, urllib.parse, time, os
|
|
|
|
UA = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"}
|
|
OUT = "/Users/drjones/astraea-books/.case-verify/snippets"
|
|
|
|
def search(q, court=None, after=None, before=None, n=6):
|
|
qq = urllib.parse.quote(q)
|
|
url = f"https://www.courtlistener.com/api/rest/v4/search/?q={qq}&type=o&format=json"
|
|
if court: url += f"&court={court}"
|
|
if after: url += f"&filed_after={after}"
|
|
if before: url += f"&filed_before={before}"
|
|
for i in range(4):
|
|
try:
|
|
req = urllib.request.Request(url, headers=UA)
|
|
with urllib.request.urlopen(req, timeout=40) as r:
|
|
return json.loads(r.read())
|
|
except Exception as e:
|
|
if i == 3: return {"error": str(e)}
|
|
time.sleep(5 + i * 5)
|
|
|
|
# (name, court, after, before, queries)
|
|
CASES = {
|
|
"Littlefield": ("wash", "1997-01-01", "1997-12-31", ["commingled trace separate community presumption", '"commingling" separate property trace', 'reverse commingling Littlefield']),
|
|
"Kovacs": ("wash", "1993-01-01", "1993-12-31", ["transmutation joint tenancy separate property", 'donative intent transmutation', 'character acquisition transmutation']),
|
|
"Chumbley": ("wash", "2003-01-01", "2003-12-31", ['commingling appreciation separate contribution', 'separate funds community funds acquisition', 'tracing formula equity']),
|
|
"Short": ("wash", "1995-01-01", "1995-12-31", ['transmutation separate property', 'commingling characterization', 'presumption community gift']),
|
|
"Borghi": ("wash", "2009-01-01", "2009-12-31", ['joint tenancy characterization intent', 'commingling separate funds', 'presumption community property title']),
|
|
"Elam": ("wash", "1982-01-01", "1982-12-31", ['gift presumption community property', 'clear and convincing separate property', 'characterization acquisition']),
|
|
"Konzen": ("wash", "1985-01-01", "1985-12-31", ['characterization date of acquisition', 'separate property commingling', 'transmutation agreement']),
|
|
"Mueller": ("washctapp", "2007-01-01", "2007-12-31", ['commingled trace separate funds', 'clear and satisfactory evidence tracing', 'Littlefield commingling account']),
|
|
"Glorfield": ("washctapp", "1980-01-01", "1980-12-31", ['transmutation separate property community', 'intent transmutation', 'gift community presumption']),
|
|
"PearsonMaines": ("washctapp", "1993-01-01", "1993-12-31", ['transmutation separate property intent', 'joint tenancy presumption gift', 'commingling characterization']),
|
|
"Olivares": ("washctapp", "1993-01-01", "1993-12-31", ['transmutation separate property', 'joint tenancy gift community', 'intent transmutation evidence']),
|
|
"Sedlock": ("washctapp", "1993-01-01", "1993-12-31", ['transmutation agreement separate community', 'joint title transmutation', 'characterization intent']),
|
|
"Hadley": ("wash", "1977-01-01", "1977-12-31", ['separate property division award', 'court may not award separate property', 'just and equitable division']),
|
|
"Schwarz": ("washctapp", "2016-01-01", "2016-12-31", ['equitable lien community funds separate property', 'commingling tracing accounts', 'reimbursement separate property mortgage']),
|
|
"Kraft": ("wash", "1992-01-01", "1992-12-31", ['separate property division dissolution', 'exceptional circumstances separate property', 'property characterization acquisition']),
|
|
"Berol": ("wash", "1950-01-01", "1950-12-31", ['deed presumption community property', 'transmutation deed separate', 'gift deed community']),
|
|
}
|
|
|
|
allout = {}
|
|
for name, (court, after, before, queries) in CASES.items():
|
|
snips = []
|
|
for q in queries:
|
|
d = search(q, court, after, before)
|
|
if "error" in d:
|
|
snips.append({"q": q, "err": d["error"]}); continue
|
|
for res in d.get("results", []):
|
|
sn = res.get("opinions", [{}])[0].get("snippet", "")
|
|
if len(sn) > 200:
|
|
snips.append({"q": q, "case": res.get("caseName"), "date": res.get("dateFiled"),
|
|
"cit": res.get("citation", [])[:2], "snip": sn})
|
|
break
|
|
time.sleep(2)
|
|
allout[name] = snips
|
|
print(f"=== {name}: {len(snips)} snippets")
|
|
for s in snips:
|
|
if "err" in s: print(" ERR", s["err"]); continue
|
|
print(" Q:", s["q"], "|", s["case"], "|", s["date"])
|
|
time.sleep(2)
|
|
|
|
json.dump(allout, open(f"{OUT}/harvest2.json", "w"), indent=1)
|
|
print("saved harvest2.json")
|