module imports

This commit is contained in:
Alexander Yakovlev 2023-03-22 07:58:05 +07:00
parent 8c0c31d6a3
commit 2c7f1a8e56
3 changed files with 7 additions and 11 deletions

View file

@ -1,4 +1,5 @@
{
"type": "module",
"dependencies": {
"mysql2": "^3.2.0",
"puppeteer": "^19.7.5"

2
run.js
View file

@ -1,4 +1,4 @@
const urq = require('./urq.js');
import urq from './urq.js'
let scraper = new urq();
scraper.page = 1;

15
urq.js
View file

@ -1,14 +1,10 @@
const puppeteer = require('puppeteer');
const mysql = require('mysql2/promise');
const config = require("./config.json");
import puppeteer from 'puppeteer';
import fs from 'fs';
import mysql from 'mysql2/promise';
async function asyncForEach (array, callback, args = []) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, args)
}
}
const config = JSON.parse(fs.readFileSync('./config.json'));
class Urq {
export default class Urq {
constructor() {
this.dbopts = {
host: 'localhost',
@ -321,4 +317,3 @@ class Urq {
}
}
module.exports = Urq;