Get Cookie & Network Traffic
Pricing
from $0.05 / 1,000 results
Get Cookie & Network Traffic
Fetch cookies and website traffic for analysis. Create a list of websites where you want to fetch your cookies and network traffic from to analyze. Run the actor *locally* on your browser with debug to get your own data, or run in the cloud to get the format/new incognito cookies and network.
Pricing
from $0.05 / 1,000 results
Rating
0.0
(0)
Developer

I G
Actor stats
0
Bookmarked
2
Total users
1
Monthly active users
6 hours ago
Last modified
Categories
Share
Cookie Getter / Generator - Apify Actor
An Apify actor that fetches or generates new cookies and website network traffic for analysis. Create a list of websites where you want to fetch your cookies and network traffic from to analyze. Run the actor locally on your browser with debug to get your own data, or run in the cloud to generate the format and get new incognito cookies and network traffic.
Description
This actor uses Puppeteer to navigate to a specified URL and extracts all cookies, scroll and generate network data.
By default, the actor uses a fresh/incognito browser session (no personal cookies).
To fetch cookies from YOUR personal browser, you have two options:
Option 1: Connect to Your Running Browser (Recommended)
Connect the actor to your currently running Chrome browser using Chrome DevTools Protocol. This allows the actor to access all your browser cookies automatically.
Option 2: Use Your Browser Profile
Launch a browser using your Chrome user data directory/profile, which contains all your saved cookies.
Using Your Browser Cookies Locally:
- Make sure all chrome tabs are closed using the command: killall "Google Chrome"
- Validate: ps ax | grep -v grep | grep "chrome"
- Start Chrome:
npm run chrome-debug - Get endpoint:
npm run get-endpoint - Add
browserWSEndpointto your INPUT.json - Run:
npm start
The actor is useful for:
- Fetching cookies from your personal browser automatically
- Getting cookies from a fresh browser session
- Extracting session cookies after visiting a site
- Understanding what cookies a website sets
Input
The actor accepts the following input:
{"url": "https://example.com","urls": ["https://example.com", "https://another-site.com"],"cookies": [{"name": "session_id","value": "abc123","domain": ".example.com","path": "/","httpOnly": true,"secure": true,"sameSite": "Lax"}],"browserWSEndpoint": "ws://localhost:9222/devtools/browser/...",}
Input Parameters
- url (required, unless
urls: The URL of the website to fetch cookies from. Can be a string (single URL) or an array of strings (multiple URLs). - urls (optional): Array of URLs to fetch cookies from. If provided,
urlis ignored. The actor will navigate to each URL sequentially and collect cookies from all of them. - cookies (optional): Array of cookies to set before navigation. Useful for authenticated requests using cookies from your personal browser.
- browserWSEndpoint (optional): Chrome DevTools Protocol WebSocket endpoint to connect to your existing Chrome session. See Connecting to Your Browser section.
- userDataDir (optional): Path to Chrome user data directory to use your browser profile.
- useExistingPage (optional, default: true): If true and
browserWSEndpointis provided, uses an existing page from your browser session instead of creating a new one.
Output
The actor outputs a JSON object. The structure depends on the mode:
Single URL Mode (default)
{"mode": "single","url": "https://example.com","cookies": [{"name": "session_id","value": "abc123","domain": ".example.com","path": "/","expires": 1234567890,"httpOnly": true,"secure": true,"sameSite": "Lax"}],"cookieCount": 1,"usedInputCookies": 0,"timestamp": "2024-01-01T00:00:00.000Z"}
Multiple URLs Mode (when urls array is provided)
{"mode": "multiple","urls": ["https://example.com", "https://another-site.com"],"results": [{"url": "https://example.com","domain": "example.com","cookies": [...],"cookieCount": 5,"finalUrl": "https://example.com/page"},{"url": "https://another-site.com","domain": "another-site.com","cookies": [...],"cookieCount": 3,"finalUrl": "https://another-site.com/home"}],"totalUrls": 2,"successfulUrls": 2,"failedUrls": 0,"totalCookies": 8,"uniqueCookieCount": 8,"usedInputCookies": 0,"timestamp": "2024-01-01T00:00:00.000Z"}
Accessing the Output
The output JSON is saved to Apify's key-value store with the key OUTPUT. You can access it in several ways:
1. Apify Console:
- Go to your actor run details page
- Click on the "Key-value store" tab
- Open the "OUTPUT" key to view/download the JSON
2. Apify API:
# Get the store ID from the run details, then:curl "https://api.apify.com/v2/key-value-stores/{STORE_ID}/records/OUTPUT?token=YOUR_API_TOKEN"
3. Programmatically:
const { Actor } = require('apify');const output = await Actor.getValue('OUTPUT');console.log(output);
Usage
Local Development
Quick Start:
# 1. Install dependenciesnpm install# 2. Create input filemkdir -p .storage/key_value_stores/defaultecho '{"url": "https://bbc.com"}' > .storage/key_value_stores/default/INPUT.json# 3. Run the actornpm start# 4. View outputcat .storage/key_value_stores/default/OUTPUT.json
Detailed Instructions:
See LOCAL_RUN.md for complete local setup guide.
Using Your Browser Cookies Locally:
- Start Chrome:
npm run chrome-debug - Get endpoint:
npm run get-endpoint - Add
browserWSEndpointto your INPUT.json - Run:
npm start
Fetching Cookies from Multiple URLs:
{"urls": ["https://example.com","https://another-site.com","https://third-site.com"],"browserWSEndpoint": "ws://localhost:9222/devtools/browser/..."}
The actor will navigate to each URL sequentially and collect cookies from all of them. Results are organized by URL in the output.
Apify Platform
- Push the actor to Apify:
$apify push
- Run the actor from the Apify console or via API with the input:
{"url": "https://example.com"}
Fetching Cookies from Your Personal Browser
The actor can automatically fetch cookies from your personal browser (Chrome, Safari, or iOS Safari). Choose one of these methods:
Method 1: Take Over Your Chrome Session (Easiest) ⭐
This connects the actor to your currently running Chrome browser session. The actor will take control of your browser, navigate to the website, and fetch cookies from that session.
Step 1: Start Chrome with Remote Debugging
Easy way (using helper script):
$npm run chrome-debug
Manual way:
On macOS:
$/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
On Linux:
$google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
On Windows:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\temp\chrome-debug"
Step 2: Get the WebSocket Endpoint
Easy way (using helper script):
$npm run get-endpoint
This will automatically find and display the WebSocket endpoint.
Manual way:
- Open
http://localhost:9222/json/versionin your browser - Copy the
webSocketDebuggerUrlvalue (looks like:ws://localhost:9222/devtools/browser/...)
Step 3: Use in Actor Input
{"url": "https://bbc.com","browserWSEndpoint": "ws://localhost:9222/devtools/browser/...","useExistingPage": true}
What happens:
- The actor connects to your existing Chrome browser
- It uses your current browser session (with all your cookies already loaded)
- It navigates to the specified URL in your browser
- It extracts all cookies from that navigation
- Your browser window will be visible and controlled by the actor
Note: Set useExistingPage: false if you want the actor to create a new tab instead of using an existing one.
For Cloud Users (Simplified):
If you're running the actor on Apify cloud, use the Cookie Extractor method below instead - it's much simpler!
Method 2: Cookie Extractor (Simplest for Cloud Users) ⭐
This is the easiest method for cloud users - no tunneling required!
Step 1: Extract Cookies Using the Web Tool
-
Open
cookie-extractor.htmlin your browser (or run the local server):npm run cookie-server# Then visit: http://localhost:3000 -
Or simply open
cookie-extractor.htmldirectly in your browser -
Visit the website you want cookies from (e.g.,
https://bbc.com) -
Open the cookie extractor page and click "Extract Cookies from Current Domain"
-
Copy the JSON output
Step 2: Use in Actor Input
{"url": "https://bbc.com","cookies": [{"name": "cookie_name","value": "cookie_value","domain": ".bbc.com","path": "/"}]}
That's it! No tunneling, no complex setup. Just extract and paste.
Method 3: Use Your Browser Profile
Launch the browser using your Chrome user data directory:
Find Your Chrome Profile Path:
- macOS:
~/Library/Application Support/Google/Chrome - Windows:
C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data - Linux:
~/.config/google-chrome
Use in Actor Input:
{"url": "https://bbc.com","userDataDir": "/path/to/your/chrome/profile"}
Note: This requires the profile to be accessible from where the actor runs (works locally, but not on Apify cloud unless you upload the profile).
Method 4: iOS Safari (iPhone/iPad) 📱
Option A: Without USB Connection (Easiest)
Extract cookies directly on your iOS device:
Step 1: Open the Cookie Extractor on iOS
- Host
ios-cookie-extractor.htmlon a web server (or use a file sharing service) - On your iOS device, open Safari
- Navigate to the website you want cookies from (e.g.,
https://bbc.com) - Open the cookie extractor page
- Click "Extract Cookies from Current Domain"
- Copy the JSON output
- Use it in your actor input
Quick Setup (Same WiFi Network):
# On your computer (same WiFi as iOS device)python3 -m http.server 8000 --bind 0.0.0.0# Find your computer's IP, then on iOS visit:# http://YOUR_IP:8000/ios-cookie-extractor.html
See ios-simple-guide.md for detailed instructions.
Option B: With USB Connection (For httpOnly Cookies)
To fetch ALL cookies including httpOnly ones (requires Mac + USB):
Prerequisites:
- Mac computer (required for Safari Web Inspector)
- iOS device connected via USB
ios-webkit-debug-proxyinstalled
Step 1: Enable Web Inspector on iOS
- On your iOS device: Settings → Safari → Advanced → Enable Web Inspector
Step 2: Connect Device to Mac
- Connect your iOS device to your Mac via USB
- Trust the computer on your device
Step 3: Set Up Proxy
# Install ios-webkit-debug-proxy (if not installed)brew install ios-webkit-debug-proxy# Start the proxynpm run ios-setup# Or manually: ios-webkit-debug-proxy
Step 4: Open Safari on iOS
- Open Safari on your iOS device
- Navigate to the website you want cookies from
Step 5: Get WebSocket Endpoint
$npm run get-endpoint
This will show the WebSocket endpoint for your iOS Safari (via the proxy).
Step 6: Use in Actor Input
{"url": "https://bbc.com","browserWSEndpoint": "ws://localhost:9222/devtools/page/..."}
Note: For cloud runs, you'll need to tunnel the connection (see Method 1 cloud setup).
See ios-setup.md for detailed instructions.
Method 5: Manual Cookie Extraction (Fallback)
If you can't use the above methods, you can run extract and pass cookies:
1. Extract Cookies from Your Browser
Chrome/Edge:
- Open Developer Tools (F12)
- Go to Application tab → Cookies
- Select the website domain
- Copy cookies as JSON or manually create the array
Using Browser Extension:
- Use extensions like "Cookie-Editor" or "EditThisCookie" to export cookies as JSON
Using JavaScript Console:
// Run this in the browser console on the target websiteJSON.stringify(document.cookie.split(';').map(c => {const [name, value] = c.trim().split('=');return { name, value, domain: window.location.hostname, path: '/' };}), null, 2)
2. Pass Cookies to the Actor
Include the cookies array in your input:
{"url": "https://example.com","cookies": [{"name": "auth_token","value": "your_token_here","domain": ".example.com","path": "/","httpOnly": true,"secure": true,"sameSite": "Lax"}]}
3. The Actor Will:
- Set your cookies before navigation
- Navigate to the URL with your authentication
- Extract all cookies (including any new ones set during the visit)
- Return both your input cookies and any new cookies
Requirements
browserWSEndpointoruserDataDirmust be provided (needs access to your browser profile)- Chrome browser with cookies stored
Usage
Step 1: Connect to Your Browser
Start Chrome with remote debugging:
$npm run chrome-debug
Step 2: Get the WebSocket Endpoint
$npm run get-endpoint
Step 3: Use in Actor Input
{"fetchAllFromHistory": true,"browserWSEndpoint": "ws://localhost:9222/devtools/browser/..."}
Note: The url field is optional when fetchAllFromHistory is true. The historyLimit parameter is not used (kept for backward compatibility).
What It Does
- Connects to your browser session
- Fetches all cookies from your browser
- Extracts unique domains from the cookies
- Organizes cookies by domain
- Returns a structured output with cookies grouped by domain
Output Structure
The output includes:
totalDomains: Number of unique domains found from cookiesdomainsWithCookies: Number of domains that have cookiestotalCookies: Total number of cookies foundcookiesByDomain: Object mapping each domain to its cookiesallCookies: Flat array of all cookies (for convenience)
Example Output
{"mode": "history","totalDomains": 45,"domainsWithCookies": 45,"totalCookies": 234,"cookiesByDomain": {"example.com": {"domain": "example.com","cookies": [...],"cookieCount": 3}},"allCookies": [...],"note": "Domains extracted from cookies in browser. Chrome DevTools Protocol does not provide access to browser history database."}
Use Cases
- Export all your browser cookies for backup
- Analyze which websites have cookies stored
- Transfer cookies to another browser or tool
- Audit your cookie usage across all domains
- Get cookies from all websites you've visited (that have cookies)
Notes
- The actor waits for the page to fully load before extracting cookies
- Some cookies may be set after page load, so the actor waits an additional 2 seconds
- Cookies are extracted from the browser's cookie store after navigation
- The actor runs in headless mode by default
- If you provide cookies, they will be set before navigation for authenticated requests
- Cookie format must match Puppeteer's cookie format (name, value, domain are required; path, expires, httpOnly, secure, sameSite are optional)