Beta Feature: Cloud Browser is currently in beta and available to staff members only.
Cloud Browser supports automatic file download handling through a custom CDP extension.
When the browser triggers a file download (PDFs, images, spreadsheets, etc.), you can retrieve the downloaded
files using special CDP commands.
How It Works
When a navigation or user action triggers a file download in the browser:
The browser intercepts the download request
The file is saved to a temporary directory on the remote browser
Download events are emitted so you can track progress
You can retrieve the file content using the ScrapiumBrowser.getDownloads command
Key Points
Files are returned as base64-encoded strings
Maximum download size is 25 MB per file
Downloads are automatically cleaned up when the session ends
Multiple file downloads are fully supported in a single session
Browser download popups and confirmations are automatically bypassed for seamless automation
Automation-Friendly: Cloud Browser automatically disables browser download protection mechanisms
(such as multiple download confirmation popups) that would normally interrupt automation scripts.
Your downloads will proceed without any user interaction required.
CDP Commands
Cloud Browser extends the standard CDP protocol with custom ScrapiumBrowser commands
for file download handling:
Command
Description
ScrapiumBrowser.getDownloads
Retrieve all downloaded files as base64-encoded content. Optionally delete files after retrieval.
ScrapiumBrowser.getDownloadsMetadatas
Get metadata (filename and size) for all downloaded files without retrieving content.
ScrapiumBrowser.getDownloads
Retrieves all files currently in the download directory, encoded as base64 strings.
This command takes no parameters.
Cloud Browser fully supports downloading multiple files in a single session. Unlike regular browsers
that may prompt for confirmation when triggering multiple downloads, Cloud Browser automatically
accepts all downloads without interruption.
Example: Downloading Multiple Files
const puppeteer = require('puppeteer-core');
const API_KEY = '';
const BROWSER_WS = `wss://browser.scrapfly.io?api_key=${API_KEY}&proxy_pool=datacenter`;
async function downloadMultipleFiles() {
const browser = await puppeteer.connect({
browserWSEndpoint: BROWSER_WS,
});
const page = await browser.newPage();
const client = await page.createCDPSession();
await page.goto('https://web-scraping.dev/file-download');
// Trigger multiple downloads - no confirmation popups will appear
await page.click('#download-btn');
await page.click('#download-pdf');
await page.click('#download-csv');
// Wait for all downloads to complete
await new Promise(resolve => setTimeout(resolve, 5000));
// Retrieve all downloaded files at once
const result = await client.send('ScrapiumBrowser.getDownloads');
console.log(`Downloaded ${Object.keys(result.files).length} files:`);
for (const [filename, base64Content] of Object.entries(result.files)) {
const buffer = Buffer.from(base64Content, 'base64');
require('fs').writeFileSync(filename, buffer);
console.log(` - ${filename} (${buffer.length} bytes)`);
}
await browser.close();
}
downloadMultipleFiles();
Tip: When downloading multiple files, you can use getDownloadsMetadatas
to check how many files are ready before retrieving them all with getDownloads.
Common Use Cases
PDF Downloads
Download PDFs generated by web applications, such as invoices, reports, or tickets
that are created dynamically after form submission or authentication.
Export Files
Retrieve data exports (CSV, Excel, JSON) from dashboards and analytics platforms
that require browser interaction to generate.
Generated Images
Download images that are generated on-demand, such as charts, QR codes,
or dynamically created graphics.
Protected Documents
Access documents behind authentication or CAPTCHA protection that can only
be downloaded through a real browser session.
Best Practices
Wait for Downloads to Complete
Always wait for the download to complete before calling getDownloads.
You can either use a fixed timeout, listen for the Browser.downloadProgress
event with state completed, or poll getDownloadsMetadatas
until files appear.
Automatic Cleanup
Downloaded files are automatically cleaned up when the browser session ends
(either when you close the CDP connection or when the session times out with auto_close=true).
You don't need to manually delete files unless you want to clear downloads during a long-running session.
Check File Size First
For large files, call getDownloadsMetadatas first to check the file size.
Remember that base64 encoding increases size by approximately 33%, so a 25 MB file
will transfer as ~33 MB of base64 data.
Handle Download Failures
Downloads can fail or be canceled. Listen to the Browser.downloadProgress
event and check for state: 'canceled' or state: 'failed'
to handle errors gracefully.
Limitations
Maximum file size: 25 MB per file
Session-scoped: Downloads are only available during the session that triggered them
Auto-cleanup: All downloads are deleted when the browser session ends
Transfer overhead: Base64 encoding adds ~33% to transfer size