Skip to content

Instantly share code, notes, and snippets.

@danielkellyio
Created November 18, 2024 15:38
Show Gist options
  • Save danielkellyio/bd8d3b9cb342a360430ef5052ba74e3a to your computer and use it in GitHub Desktop.
Save danielkellyio/bd8d3b9cb342a360430ef5052ba74e3a to your computer and use it in GitHub Desktop.
const pw = require('playwright');
const AUTH = '...';
const SBR_CDP = `wss://${AUTH}@brd.superproxy.io:9222`;
async function main() {
console.log('Connecting to Scraping Browser...');
const browser = await pw.chromium.connectOverCDP(SBR_CDP);
try {
console.log('Connected! Navigating...');
const page = await browser.newPage();
await page.goto('https://amazon.com',{ timeout: 2 * 60 * 1000 });
console.log('Taking screenshot to page.png');
await page.screenshot({ path: './page.png', fullPage: true });
console.log('Navigated! Scraping page content...');
const html = await page.content();
console.log(html);
} finally {
await browser.close();
}
}
if (require.main === module) {
main().catch(err => {
console.error(err.stack || err);
process.exit(1);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment