This template shows you how to use Steel with Puppeteer to run browser automations in the cloud on Val Town. It includes session management, error handling, and a basic example you can customize. This starter templated was ported from this one on Github.
The script shows you how to:
To run it:
STEEL_API_KEY
Fork
on this valRun
on this valFind this section in the script:
// ============================================================
// Your Automations Go Here!
// ============================================================
// Example automation (you can delete this)
await page.goto('https://news.ycombinator.com');
// ... rest of example code
You can replace the code here with whatever automation scripts you want to run.
The template includes common Steel configurations you can enable:
const session = await client.sessions.create({
useProxy: true, // Use Steel's proxy network
solveCaptcha: true, // Enable CAPTCHA solving
sessionTimeout: 1800000, // 30 minute timeout (default: 15 mins)
userAgent: 'custom-ua', // Custom User-Agent
});
The template includes error handling and cleanup:
try {
// Your automation code
} finally {
// Cleanup runs even if there's an error
if (browser) await browser.close();
if (session) await client.sessions.release(session.id);
}