Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic proxy chage in page #1861

Closed
AlexBGD opened this issue Jan 19, 2018 · 20 comments
Closed

Dynamic proxy chage in page #1861

AlexBGD opened this issue Jan 19, 2018 · 20 comments

Comments

@AlexBGD
Copy link

AlexBGD commented Jan 19, 2018

I want to change proxy on every repuest without closing and Opening the browser again. First set proxy here:

const browser = await puppeteer.launch({
args: ['--proxy-server='+proxy
});

So my goal is to change proxy on every request, not to have only one proxy per browser.
Thanks!

@shtefcs
Copy link

shtefcs commented Jan 22, 2018

This is something we are thinking of to. Let's see how it goes.

@qingpengchen2011
Copy link

+1

@Nicolas-vrcc
Copy link

+1 plz halp

@ebidel
Copy link
Contributor

ebidel commented Feb 2, 2018

Dupe oc #678

@ebidel ebidel closed this as completed Feb 2, 2018
@paynoattn
Copy link

+1

4 similar comments
@yi-ge
Copy link

yi-ge commented Dec 22, 2018

+1

@waseemshahwan
Copy link

+1

@francima961
Copy link

+1

@adrian-chang-alcover
Copy link

+1

@xse
Copy link

xse commented Apr 25, 2019

You might be able to achieve that with an extension.

@shtefcs
Copy link

shtefcs commented Apr 25, 2019

You might be able to achieve that with an extension.

Can you use chrome extensions inside puppeteer ?

@xse
Copy link

xse commented Apr 25, 2019

Can you use chrome extensions inside puppeteer ?

Yes you can use extensions with puppeteer, given that extensions can be used to change proxy and that extensions can know about requests, i feel like this might be doable.
Like you might be able to proxy each requests from your own extension for example.

@xiyuan-fengyu
Copy link

try this PuppeteerUtil.useProxy

@yi-ge
Copy link

yi-ge commented Jun 2, 2019

@xiyuan-fengyu use http-proxy-agent to tackle Puppeteer proxy, this is a good idea! thank you.

@Cuadrix
Copy link

Cuadrix commented Feb 9, 2020

It's possible with puppeteer-page-proxy.
It supports setting a proxy for an entire page, or if you like, it can set a different proxy for each request.

First install it:

npm i puppeteer-page-proxy

Then require it:

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

Using it is easy;
Set proxy for an entire page:

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

If you want a different proxy for each request,then you can simply do this:

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

Then if you want to be sure that your page's IP has changed, you can look it up;

const data = await useProxy.lookup(page);
console.log(data.ip);

It supports http, https, socks4 and socks5 proxies, and it also supports authentication if that is needed:

const proxy = 'http://login:pass@127.0.0.1:8000'

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

@dmitryshelomanov
Copy link

@Cuadrix is not working, "Provisional headers are shown" message + can't extract request cookies

@badman666
Copy link

@Cuadrixне работает, сообщение «Показаны предварительные заголовки» + не удается извлечь файлы cookie запроса

+1

@makanSukros
Copy link

It's possible with puppeteer-page-proxy. It supports setting a proxy for an entire page, or if you like, it can set a different proxy for each request.

First install it:

npm i puppeteer-page-proxy

Then require it:

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

Using it is easy; Set proxy for an entire page:

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

If you want a different proxy for each request,then you can simply do this:

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

Then if you want to be sure that your page's IP has changed, you can look it up;

const data = await useProxy.lookup(page);
console.log(data.ip);

It supports http, https, socks4 and socks5 proxies, and it also supports authentication if that is needed:

const proxy = 'http://login:pass@127.0.0.1:8000'

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

Invalid, Getting Error: net::ERR_FAILED

@ktmohammedsulaim
Copy link

It's possible with puppeteer-page-proxy. It supports setting a proxy for an entire page, or if you like, it can set a different proxy for each request.
First install it:

npm i puppeteer-page-proxy

Then require it:

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

Using it is easy; Set proxy for an entire page:

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

If you want a different proxy for each request,then you can simply do this:

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

Then if you want to be sure that your page's IP has changed, you can look it up;

const data = await useProxy.lookup(page);
console.log(data.ip);

It supports http, https, socks4 and socks5 proxies, and it also supports authentication if that is needed:

const proxy = 'http://login:pass@127.0.0.1:8000'

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

Invalid, Getting Error: net::ERR_FAILED

Same here. Any update on the issue?

@JijaProGamer
Copy link

Thats a proxy issue. I use puppeteer-page-proxy daily and it works just fine. Use premium proxies if you want it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests