JimmyLaurent / cloudflare-scraper

A package to bypass Cloudflare's protection
MIT License
289 stars 30 forks source link

tunneling error when try with a proxy #32

Open Mr-ZQS opened 3 years ago

Mr-ZQS commented 3 years ago
error: Error: tunneling socket could not be established, cause=read ECONNRESET
      at ClientRequest.onError (C:\*****\node_modules\tunnel-agent\index.js:177:17)
      at Object.onceWrapper (events.js:422:26)
      at ClientRequest.emit (events.js:315:20)
      at Socket.socketErrorListener (_http_client.js:426:9)
      at Socket.emit (events.js:315:20)
      at emitErrorNT (internal/streams/destroy.js:92:8)
      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
    code: 'ECONNRESET'
  },

code used

(async () => {
    try {
        const jar = cloudflareScraper.jar();
        const url = 'site';
        const response = await cloudflareScraper.get(url, {
            jar,
            headers: defaultHeaders,
            proxy: proxyServer
        });
        const cookiesObject = jar.getCookies(url);
        const cookieJson = JSON.stringify(cookieObject, null, 2);
        const cookieStr = jar.getCookieString(url);
        console.log(cookieStr);
    } catch (error) {
        console.log(`Error :`, error/*.statusCode, error.error*/);
    }
})()