eshaham / israeli-bank-scrapers

Provide scrapers for all major Israeli banks and credit card companies
MIT License
587 stars 160 forks source link

`createScraper` Fails to Recognize `executablePath` #790

Open shaimalul opened 1 year ago

shaimalul commented 1 year ago

While integrating executablePath into the createScraper function, an error is encountered:

const executablePath = await getChromiumExecutablePath();
const options: ScraperOptions = {
  companyId: companyType,
  startDate,
  combineInstallments: false,
  showBrowser: false,
  executablePath,
};
const scraper = createScraper(options);

The executablePath value typically is like: my-project\node_modules\download-chromium/.local-chromium/chromium-win64-843427/chrome-win/chrome.exe.

However, this error is thrown: scraping failed for the following reason: Error: ENOENT: no such file or directory, mkdtemp 'undefined\temp\puppeteer_dev_chrome_profile-XXXXXX'.

Below is the getChromiumExecutablePath function:

import { getPuppeteerConfig } from 'israeli-bank-scrapers-core';
import Logging from '../library/Logging';

const download = require('download-chromium');

export async function getChromiumExecutablePath(): Promise<string> {
  const chromiumRevision = getPuppeteerConfig().chromiumRevision;
  Logging.info(`chromiumRevision: ${chromiumRevision}`);
  let path;
  try {
    path = await download({
      revision: chromiumRevision,
    });
  } catch (error) {
    Logging.error(`Error on downloading chrome: ${error}`);
  }
  Logging.info(`path: ${path}`);
  return path;
}

Expected Behavior: The createScraper function should recognize and accept the executablePath supplied without throwing the error above.

Current Behavior: Currently, the createScraper function throws an error when executablePath is provided.

Potential Solutions or Suggestions: Could this be a file path issue related to Chromium's installation directory, or perhaps an issue with download-chromium? Any insights or suggestions would be much appreciated.

esakal commented 1 year ago

Hello, Sorry for the late response. Can you reply with the value you got from

  path = await download({
      revision: chromiumRevision,
    });
niv280 commented 1 year ago

I got the same issue the path var for me is: /home/ni/test/node_modules/download-chromium/.local-chromium/chromium-linux-843427/chrome-linux/chrome

shaimalul commented 1 year ago

@esakal locally is the path: temp/chromium-win64-843427/chrome-win/chrome.exe