import puppeteer from "puppeteer-core";
//puppeteer 다운 받은 것을 임포트 시킨다.
import os from 'os'
import fs from 'fs'
const macUrl = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
// Chrome browser로 실행시킬 것이기에 chrome.exe가 있는 경로를 입력
const whidowsUrl = 'C:/Program Files (x86)/Google/Chrome/Application/Chrome.exe'
const currentOs = os.type()
const launchConfig = {
headless: false,
defaultViewport: null,
ignoreDefaultArgs: ['--disable-extensions'],
args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-notifications', '--disable-extensions'],
executablePath: currentOs == 'Darwin' ? macUrl : whidowsUrl
}
//전역변수
let browser = null
let page = null
let pageLength = 0
const pageSelector = ""
//실행함수
const launch = async function(){
browser = await puppeteer.launch(launchConfig);
const pages = await browser.pages();
console.log(pages.length)
page = pages[0]
}
export {
launch
}
import { launch } from './modules/crawler.js'
async function main() {
await launch()
}
main()
첫번 째 오류 !! 모듈을 찾을 수 없다고 한다.
(해결)