A tool to capture and save JSON responses from web requests using Playwright. It's particularly useful for capturing API responses from web applications for testing or development purposes.
- Node.js
- pnpm or npm
- Playwright
- Install dependencies:
pnpm install
# or
npm install- Install Playwright browsers:
npx playwright install- Create a
.cookiefile in the root directory with your session token:
your_session_token_here
The basic command structure is:
node index.js --url <required-url> [options]--url,-u: URL to fetch responses from- Required: Yes
- Example:
--url "https://api.example.com"
-
--output-dir,-o: Directory where JSON responses will be saved- Default: "./json_responses"
- Example:
--output-dir "./my_responses"
-
--headless: Whether to run the browser in headless mode- Default: true
- Example:
--headless false(to see the browser)
-
--session-name,-s: Name of the session cookie- Default: "session"
- Example:
--session-name "my_session"
-
--help: Show help information
# Basic usage with required URL
node index.js --url "https://api.example.com"
# Specify custom output directory
node index.js --url "https://api.example.com" --output-dir "./responses"
# Run with visible browser and custom session name
node index.js --url "https://api.example.com" --headless false --session-name "my_session"- The tool launches a Playwright browser instance
- Loads your authentication cookie from the
.cookiefile - Navigates to the specified URL
- Captures all JSON responses from the domain
- Saves responses as individual JSON files in the output directory
- Waits for 15 seconds to capture async requests
- Automatically closes the browser
- JSON responses are saved in the specified output directory
- Filenames are generated from the request URLs (sanitized and truncated)
- JSON is pretty-printed for readability
- Only JSON responses (content-type: application/json) are captured
- Only responses from the same domain as the target URL are saved
- The tool requires a valid session token in the
.cookiefile - The browser stays open for 15 seconds to capture async requests
This project is licensed under the MIT License - see the LICENSE file for details.