36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
|
|
import io, urllib.parse, urllib.request
|
||
|
|
from pathlib import Path
|
||
|
|
from pypdf import PdfReader
|
||
|
|
|
||
|
|
JEI = Path(r"C:\Users\SJ\.minimax-agent\projects\JEI")
|
||
|
|
env = {}
|
||
|
|
for line in (JEI / ".env.local").read_text(encoding="utf-8").splitlines():
|
||
|
|
line = line.strip()
|
||
|
|
if line and not line.startswith("#") and "=" in line:
|
||
|
|
k, v = line.split("=", 1)
|
||
|
|
env[k.strip()] = v.strip().strip('"').strip("'")
|
||
|
|
PB = env.get("NEXT_PUBLIC_PB_URL") or env["PB_URL"]
|
||
|
|
TOK = env["PB_TOKEN"]
|
||
|
|
|
||
|
|
TARGETS = [
|
||
|
|
("STORED resolution.signed_letter", "pbc_266170881", "e0dbxprazb70rqx", "corrected_v2_avwpnq7o93.pdf"),
|
||
|
|
("STORED resignation.letter", "ysterbaard_director_resignations", "8cfie18uhgy0n0o",
|
||
|
|
"resignation_letter_the_ultimate_fuel_company_1jk8t34nf3.pdf"),
|
||
|
|
("STORED resignation.signature", "ysterbaard_director_resignations", "8cfie18uhgy0n0o",
|
||
|
|
"tbde1evt2m6_8mz8kutpki.pdf"),
|
||
|
|
]
|
||
|
|
|
||
|
|
for label, col, rid, fname in TARGETS:
|
||
|
|
url = f"{PB}/api/files/{col}/{rid}/{urllib.parse.quote(fname)}"
|
||
|
|
req = urllib.request.Request(url, headers={"Authorization": TOK})
|
||
|
|
with urllib.request.urlopen(req, timeout=120) as r:
|
||
|
|
b = r.read()
|
||
|
|
reader = PdfReader(io.BytesIO(b))
|
||
|
|
print("=" * 78)
|
||
|
|
print(f"{label} ({fname}) pages={len(reader.pages)}")
|
||
|
|
print("=" * 78)
|
||
|
|
for i, p in enumerate(reader.pages):
|
||
|
|
t = p.extract_text() or ""
|
||
|
|
print(f"--- page {i+1} ---")
|
||
|
|
print(t.strip())
|
||
|
|
print()
|