
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
puppeteer-page-proxy
Advanced tools
Additional Node.js module to use with 'puppeteer' for setting proxies per page basis.
Additional Node.js module to use with 'puppeteer' for setting proxies per page basis.
Uses (http | https | socks)-proxy-agent to achieve the desired results.
This small module consists of a class and a function taken from ppspider.
All credit for the original code goes to the author @xiyuan-fengyu.
npm i puppeteer-page-proxy
page
<object> Page object to set a proxy for.proxy
<string> Proxy to use in the current page. Must begin with a protocol e.g. http://, https://, socks://.enableCache
<boolean> Whether to enable caching. Defaults to true
.page
<object> Page object to execute the request on.lookupService
<string> External lookup service to request data from. Fetches data from api.ipify.org
by default.isJSON
<boolean> Whether to JSON.parse the received response. Defaults to true
.timeout
<number|string> Time in milliseconds after which the request times out. Defaults to 30000
ms.const puppeteer = require('puppeteer');
const useProxy = require('puppeteer-page-proxy');
(async () => {
let site = 'https://example.com';
let proxy1 = 'http://host:port';
let proxy2 = 'https://host:port';
let proxy3 = 'socks://host:port';
const browser = await puppeteer.launch({headless: false});
const page1 = await browser.newPage();
await useProxy(page1, proxy1);
await page1.goto(site);
const page2 = await browser.newPage();
await useProxy(page2, proxy2);
await page2.goto(site);
const page3 = await browser.newPage();
await useProxy(page3, proxy3);
await page3.goto(site);
})();
const puppeteer = require('puppeteer');
const useProxy = require('puppeteer-page-proxy');
(async () => {
let site = 'https://example.com';
let proxy1 = 'http://host:port';
let proxy2 = 'https://host:port';
const browser = await puppeteer.launch({headless: false});
/**1*/
const page1 = await browser.newPage();
await useProxy(page1, proxy1);
let data = await useProxy.lookup(page1); // Waits until done, "then" continues
console.log(data.ip);
await page1.goto(site);
/**2*/
const page2 = await browser.newPage();
await useProxy(page2, proxy2);
useProxy.lookup(page2).then(data => { // Executes and "comes back" once done
console.log(data.ip);
});
await page2.goto(site);
})();
FAQs
Additional Node.js module to use with 'puppeteer' for setting proxies per page basis.
The npm package puppeteer-page-proxy receives a total of 1,811 weekly downloads. As such, puppeteer-page-proxy popularity was classified as popular.
We found that puppeteer-page-proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.