Cuadrix / puppeteer-page-proxy

Additional module to use with 'puppeteer' for setting proxies per page basis.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: useProxyPer[target.constructor.name] is not a function

io-store opened this issue · comments

When I use the useProxy function I get this error:

  • TypeError: useProxyPer[target.constructor.name] is not a function

code:
const puppeteer = require('puppeteer');
const useProxy = require('puppeteer-page-proxy');
(async () => {
var proxy = "ip:port:username:password".split(":");
proxy = 'http://'+proxy[2]+':'+proxy[3]+'@'+proxy[0]+':'+proxy[1];
const browser = await puppeteer.launch({
args: ['--disable-web-security'],
executablePath:"C:\Program Files\Google\Chrome\Application\chrome.exe",
headless:false,
});
const page = await browser.newPage();
await useProxy(page, proxy);
await page.goto('https://www.google.com/search?q=what+is+my+ip+address');
await new Promise(reslove => setTimeout(reslove,1000));
await browser.close();
})();
i want help please

NodeJS Version: 20.9.0
npm Version: 10.1.0
package version: 1.3.0

  • Note
    • i used @lem0-packages/puppeteer-page-proxy also but showing me that
    | TypeError: Cannot read properties of undefined (reading 'get')

When I use the useProxy function I get this error:

  • TypeError: useProxyPer[target.constructor.name] is not a function

code: const puppeteer = require('puppeteer'); const useProxy = require('puppeteer-page-proxy'); (async () => { var proxy = "ip:port:username:password".split(":"); proxy = 'http://'+proxy[2]+':'+proxy[3]+'@'+proxy[0]+':'+proxy[1]; const browser = await puppeteer.launch({ args: ['--disable-web-security'], executablePath:"C:\Program Files\Google\Chrome\Application\chrome.exe", headless:false, }); const page = await browser.newPage(); await useProxy(page, proxy); await page.goto('https://www.google.com/search?q=what+is+my+ip+address'); await new Promise(reslove => setTimeout(reslove,1000)); await browser.close(); })(); i want help please

NodeJS Version: 20.9.0 npm Version: 10.1.0 package version: 1.3.0

  • Note
    • i used @lem0-packages/puppeteer-page-proxy also but showing me that
    | TypeError: Cannot read properties of undefined (reading 'get')

You can create a CdpHTTPRequest in useProxyPer with the same code as HTTPRequest

const useProxyPer = {
...
CdpHTTPRequest: async (request, data) => {
      let proxy, overrides;
      // Separate proxy and overrides
      if (type(data) === "object") {
          if (Object.keys(data).length !== 0) {
              proxy = data.proxy;
              delete data.proxy;
              overrides = data;
          }
      } else {proxy = data}
      // Skip request if proxy omitted
      if (proxy) {await requestHandler(request, proxy, overrides)}
      else {request.continue(overrides)}
  }
...
}