JimmyLaurent / cloudflare-scraper

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

Electron.js workaround for puppeteer #13

Closed Revadike closed 4 years ago

Revadike commented 4 years ago

https://github.com/puppeteer/puppeteer/issues/2134#issuecomment-408221446

This shouldn't affect anything else.

JimmyLaurent commented 4 years ago

You should be able to override puppeteer options in the last version.

const puppeteer = require('puppeteer');
const cloudflareScraper = require('cloudflare-scraper');

(async () => {
  try {
    const response = await cloudflareScraper.get('https://cloudflare-url.com', {
       puppeteerOptions: { 
          executablePath: puppeteer.executablePath().replace('app.asar', 'app.asar.unpacked') 
       }
    });
    console.log(response);
  } catch (error) {
    console.log(error);
  }
})();
Revadike commented 4 years ago

You should be able to override puppeteer options in the last version.

const puppeteer = require('puppeteer');
const cloudflareScraper = require('cloudflare-scraper');

(async () => {
  try {
    const response = await cloudflareScraper.get('https://cloudflare-url.com', {
       puppeteerOptions: { 
          executablePath: puppeteer.executablePath().replace('app.asar', 'app.asar.unpacked') 
       }
    });
    console.log(response);
  } catch (error) {
    console.log(error);
  }
})();

Does this also work for the .defaults(/* ... */) method?

JimmyLaurent commented 4 years ago

I think so.