Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Builder, By } = require('selenium-webdriver');
- const firefox = require('selenium-webdriver/firefox');
- async function scraper() {
- // set the browser options
- const options = new firefox.Options().addArguments('--headless');
- // initialize the webdriver
- const driver = new Builder()
- .forBrowser('firefox')
- .setFirefoxOptions(options)
- .build();
- try {
- // navigate to target website
- await driver.get('https://httpbin.io/ip');
- // get the page text content
- const pageText = await driver.findElement(By.css('body')).getText();
- console.log(pageText);
- } catch (error) {
- console.error('An error occurred:', error);
- } finally{
- await driver.quit();
- }
- }
- scraper();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement