small fixes and upgrades
This commit is contained in:
parent
cb02947a1c
commit
7b050cbfaa
16
src/core.ts
16
src/core.ts
@ -34,11 +34,12 @@ import {
|
||||
Coolblue
|
||||
} from "./modules/websites";
|
||||
|
||||
// start();
|
||||
debugStart();
|
||||
start();
|
||||
// debugStart();
|
||||
|
||||
// Globals
|
||||
let browser: puppeteer.Browser = null;
|
||||
let sitemapUrl: string = "";
|
||||
let allProducts: Array<any> = [];
|
||||
let allBlogUrls: Array<any> = [];
|
||||
|
||||
@ -54,9 +55,10 @@ async function start() {
|
||||
|
||||
// Get sitemap url from process params
|
||||
let params = process.argv.slice(2);
|
||||
sitemapUrl = params[0];
|
||||
|
||||
// Crawl Sitemap
|
||||
const sitemap = await got(params[0]);
|
||||
const sitemap = await got(sitemapUrl);
|
||||
const $ = cheerio.load(sitemap.body, { xmlMode: true })
|
||||
|
||||
$('loc').each(function() {
|
||||
@ -290,8 +292,12 @@ async function crawlProductStock(url: string) {
|
||||
|
||||
async function generateReport() {
|
||||
console.log("Generating report...");
|
||||
|
||||
let file = `stock-report.txt`;
|
||||
|
||||
let today: Date = new Date();
|
||||
let datecode: string = today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDay().toString();
|
||||
let domain: string = getDomain(sitemapUrl);
|
||||
let file = `${domain}-${datecode}-report.txt`;
|
||||
|
||||
let totalProducts = 0;
|
||||
let totalOutStock = 0;
|
||||
for (let product of allProducts) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user