Created
December 25, 2024 06:04
-
-
Save uratmangun/4e1a653e82f5ab45e9e6cfa51ac699dc 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
import * as pw from '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://example.com', { timeout: 2 * 60 * 1000 }); | |
console.log('Navigated! Scraping page content...'); | |
const title = await page.title(); | |
console.log(title); | |
} finally { | |
await browser.close(); | |
} | |
} | |
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