Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // import the required libraries
- const { Builder, By } = require('selenium-webdriver');
- const firefox = require('selenium-webdriver/firefox');
- const proxy = require('selenium-webdriver/proxy');
- async function scraper() {
- // define your proxy details
- const proxyString = `167.99.174.59:80`;
- // set the browser options
- const options = new firefox.Options().addArguments('--headless');
- // initialize the webdriver
- const driver = new Builder()
- .forBrowser('firefox')
- // add the proxy to the webdriver
- .setProxy(proxy.manual({
- http: proxyString,
- https: proxyString,
- }))
- .setFirefoxOptions(options)
- .build();
- try {
- // navigate to target website
- await driver.get('https://httpbin.io/ip');
- await driver.sleep(8000);
- // get the page text content
- const pageText = await driver.findElement(By.tagName('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