NYSCAttach (pronounced Nisk-attach): The NY Courts eNotify Attachment Downloader
A Python script to download all PDF attachments from a NY Courts eNotify inbox, while working with Cloudflare protections and the iapps viewer token flow.
This project uses Playwright to attach to a real, human-driven Chrome session via the Chrome DevTools Protocol (CDP). It does not attempt to bypass Cloudflare. Instead, it leverages the already-authenticated browser session to retrieve attachments safely and reliably.
The NY Courts eNotify system:
- Is protected by Cloudflare
- Requires a valid login session
- Serves attachments via a redirect to:
https://iapps.courts.state.ny.us/vscms_public/viewer?action=inline&token=...
Common automation approaches fail because:
- Direct HTTP requests receive 403 "Just a moment..." responses from Cloudflare
- The Chrome PDF viewer returns a small HTML wrapper instead of the actual PDF bytes
- The iapps viewer URL requires a valid browser session and token
This script works by:
- Attaching to a real Chrome instance (already logged in)
- Calling the internal
/api/inboxendpoint via in-pagefetch - Navigating to each attachment URL to capture the 302 redirect
- Extracting the
Locationheader (iapps viewer token URL) - Downloading the PDF using the browser context
- Verifying the file starts with
%PDF-before saving
- Python 3.9+
- Google Chrome
- Playwright (Python)
Install dependencies:
pip install playwright
python -m playwright install chromium
Start Chrome with a persistent profile and remote debugging enabled:
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/nycourts-profile
Important: - Do not close this browser while the script is running. - Use the same profile directory every time.
In the opened Chrome window:
- Go to https://enotify.nycourts.gov/
- Log in manually
- Complete any Cloudflare verification
- Navigate to the Inbox page
Leave the browser open on the Inbox.
python downloader_redirect_pdf.py
The script will:
- Iterate through inbox pages
- Open each message with attachments
- Download all PDFs into:
./downloads/<message_guid>/
It maintains a _download_log.json file to avoid re-downloading files.
Cloudflare blocks direct API or HTTP client access.
This script avoids that by:
- Using
connect_over_cdp()to attach to the real Chrome session - Executing
/api/inboxcalls viawindow.fetch()inside the page - Performing attachment navigation in a real browser tab
No headless automation is used for login.
For each attachment:
-
Navigate to:
/Inbox/<guid>/Attachment/<id> -
Capture the 302 redirect response.
-
Extract:
https://iapps.courts.state.ny.us/vscms_public/viewer?...token=... -
Download that URL.
-
Verify the first bytes are:
%PDF- -
Save as a
.pdffile.
This avoids saving the Chrome PDF viewer wrapper (which is ~536 bytes of HTML).
downloads/
<message_guid>/
001_<attachment_name>.pdf
002_<attachment_name>.pdf
_download_log.json
The log file stores:
- Attachment ID
- iapps token URL
- Timestamp
- File size
- The script does not attempt to bypass Cloudflare.
- It requires an already-authenticated human session.
- It intentionally adds small delays between downloads to avoid flooding requests.
- If a file does not begin with
%PDF-, it will not be saved.
- Requires a running Chrome instance.
- Token URLs are short-lived and must be used immediately.
- Large inboxes may take significant time to process.
This tool is intended only for downloading documents from your own authorized NY Courts eNotify account.
You are responsible for complying with all applicable laws, court rules, and terms of service.
GNUGPLv3