DEV Community

Discussion on: Practical Puppeteer: Using proxy to browse a page

Collapse
 
cuadrix profile image
Cuadrix

I created a module for that. It's very simple to use,
First install it:

npm i puppeteer-page-proxy

Then require it:

const useProxy = require('puppeteer-page-proxy');

And then simply use it. To set a proxy for an entire page, do this:

await useProxy(page, 'http://127.0.0.1:771');

Or if you want to set it per requests, just do this:

await page.setRequestInterception(true);
page.on('request', req => {
    useProxy(req, 'socks5://127.0.0.1:9000');
});

Repository: github.com/Cuadrix/puppeteer-page-...

Collapse
 
sonyarianto profile image
Sony AK

Hi Cuadrix, thanks for the addition. This is cool and more natural for human :)