playwrightvsselenium-driverless
Playwright is a Node.js library that provides a high-level API to automate web browsers. It allows you to automate browser tasks such as generating screenshots, creating PDFs, and testing web pages by simulating user interactions. Playwright is similar to Puppeteer, but it supports more browsers and it also provide capabilities for automation of browser like Microsoft Edge and Safari.
Playwright is commonly used for web scraping, end-to-end testing, and browser automation.
Playwright is a spiritual successor to Puppeter and is available in more languages and has access to more browser types.
Selenium Driverless is a Selenium inspired browser automation library with focus on web scraping detection bypass. It shares most of Selenium API and UX but implements several extensions that make the scraper more difficult to detect and extra usability features like: - Bypass Cloudflare - Multiple Tab scraping - Multiple context support - Proxy auth - Network interception
Example Use
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://www.example.com/form');
// fill in the form
await page.fill('input[name="name"]', 'John Doe');
await page.fill('input[name="email"]', 'johndoe@example.com');
await page.selectOption('select[name="country"]', 'US');
// submit the form
await page.click('button[type="submit"]');
// wait for the page to load after the form is submitted
await page.waitForNavigation();
// take a screenshot
await page.screenshot({path: 'form-submission.png'});
await browser.close();
})();
# It works the same as Selenium just with a different import.
import undetected_chromedriver as uc
driver = uc.Chrome(headless=True, use_subprocess=False)
driver.get('https://nowsecure.nl')
driver.save_screenshot('screenshot.png')
driver.close()