Created
November 18, 2024 15:38
-
-
Save danielkellyio/bd8d3b9cb342a360430ef5052ba74e3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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