Last active
January 15, 2020 19:38
-
-
Save Raidus/161b6c148efe4a3f89c5728e7254d274 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
// Reference: https://blog.apify.com/how-to-make-headless-chrome-and-puppeteer-use-a-proxy-server-with-authentication-249a21a79212 | |
const puppeteer = require('puppeteer'); | |
const proxyChain = require('proxy-chain'); | |
const { PROXYMESH_USER, PROXYMESH_PASSWORD } = require('../config/keys'); | |
(async () => { | |
const oldProxyUrl = `http://${PROXYMESH_USER}:${PROXYMESH_PASSWORD}@de.proxymesh.com:31280`; | |
const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl); | |
const browser = await puppeteer.launch({ | |
args: [`--proxy-server=${newProxyUrl}`], | |
}); | |
const page = await browser.newPage(); | |
await page.goto('https://google.com', { waitUntil: 'networkidle2' }); | |
await page.screenshot({ path: './tmp/proxymesh_service.png' }); | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment