You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 2 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* eslint-disable global-require */
  2. /* eslint-disable import/no-extraneous-dependencies */
  3. const findChrome = require('carlo/lib/find_chrome');
  4. const getBrowser = async () => {
  5. try {
  6. // eslint-disable-next-line import/no-unresolved
  7. const puppeteer = require('puppeteer');
  8. const browser = await puppeteer.launch({
  9. args: [
  10. '--disable-gpu',
  11. '--disable-dev-shm-usage',
  12. '--no-first-run',
  13. '--no-zygote',
  14. '--no-sandbox',
  15. ],
  16. });
  17. return browser;
  18. } catch (error) {
  19. // console.log(error)
  20. }
  21. try {
  22. // eslint-disable-next-line import/no-unresolved
  23. const puppeteer = require('puppeteer-core');
  24. const findChromePath = await findChrome({});
  25. const { executablePath } = findChromePath;
  26. const browser = await puppeteer.launch({
  27. executablePath,
  28. args: [
  29. '--disable-gpu',
  30. '--disable-dev-shm-usage',
  31. '--no-first-run',
  32. '--no-zygote',
  33. '--no-sandbox',
  34. ],
  35. });
  36. return browser;
  37. } catch (error) {
  38. console.log('🧲 no find chrome');
  39. }
  40. throw new Error('no find puppeteer');
  41. };
  42. module.exports = getBrowser;