LeM0-Dev / puppeteer-page-proxy

Additional module to use with 'puppeteer' for setting proxies per page basis.
17 stars 4 forks source link

Use setCookie with useProxy together #7

Closed mrickymuliawan closed 3 months ago

mrickymuliawan commented 3 months ago

Hi my project is using puppeteer-cluster and i want. to use setCookie with the proxy, if i use the proxy, the cookies did not want to set. please help this issue. thank you

Biswajit96 commented 3 months ago

did you try page.setCookie?

const browser = await puppeteer.launch(); const page = await browser.newPage(); await useProxy(page, 'http://127.0.0.1:80'); await page.goto('https://example.com');

const cookies = [ { name: 'cookie1', value: 'val1', domain: 'example.com' }, { name: 'cookie2', value: 'val2', domain: 'example.com' }, { name: 'cookie3', value: 'val3', domain: 'example.com' } ];

await page.setCookie(...cookies);

// Verify cookies are set const cookiesSet = await page.cookies('https://example.com'); console.log(JSON.stringify(cookiesSet));