Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { chromium } = require(“playwright”);
- (async () => {
- // Launch a browser
- const browser = await chromium.launch();
- // Create a new browser context
- const context = await browser.newContext();
- // Create a new page within the context
- const page = await context.newPage();
- try {
- // List of URLs to scrape
- const urls = [“https://example.com”, “https://example.com/page2”, /* Add more URLs */];
- // Loop through the URLs
- for (const url of urls) {
- // Navigate to url
- await page.goto(url);
- // Introduce a delay before the next request
- await page.waitForTimeout(2000);
- }
- } finally {
- // Close the browser
- await browser.close();
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement