pushing for testing
This commit is contained in:
parent
b8965e2e3e
commit
1376b14e2a
1 changed files with 8 additions and 2 deletions
|
@ -19,13 +19,15 @@ export class CrawlerService {
|
||||||
// STYLESHEETS //
|
// STYLESHEETS //
|
||||||
const stylesheetsUrls = await page.$$eval('link[rel="stylesheet"]', links => links.map(link => link.href));
|
const stylesheetsUrls = await page.$$eval('link[rel="stylesheet"]', links => links.map(link => link.href));
|
||||||
let cssDir = `${directory}/css/`
|
let cssDir = `${directory}/css/`
|
||||||
await this.downloadFiles(stylesheetsUrls, cssDir);
|
const cssSheetsLocation = await this.downloadFiles(stylesheetsUrls, cssDir);
|
||||||
|
console.log(`cssSheetsLocation: `, cssSheetsLocation);
|
||||||
// STYLESHEETS //
|
// STYLESHEETS //
|
||||||
|
|
||||||
// SCRIPTS //
|
// SCRIPTS //
|
||||||
const scriptsUrls = await page.$$eval('script', scripts => scripts.map(script => script.src));
|
const scriptsUrls = await page.$$eval('script', scripts => scripts.map(script => script.src));
|
||||||
let scriptsDir = `${directory}/scripts/`
|
let scriptsDir = `${directory}/scripts/`
|
||||||
await this.downloadFiles(scriptsUrls, scriptsDir);
|
const scriptsSheetsLocation = await this.downloadFiles(scriptsUrls, scriptsDir);
|
||||||
|
console.log(`scriptsSheetsLocation: `, scriptsSheetsLocation)
|
||||||
// SCRIPTS //
|
// SCRIPTS //
|
||||||
|
|
||||||
// SCREENSHOT //
|
// SCREENSHOT //
|
||||||
|
@ -42,6 +44,7 @@ export class CrawlerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadFiles(urls: string[], path: string) {
|
async downloadFiles(urls: string[], path: string) {
|
||||||
|
const finalUrls = [];
|
||||||
if (!fs.existsSync(path)) {
|
if (!fs.existsSync(path)) {
|
||||||
mkdirSync(path);
|
mkdirSync(path);
|
||||||
}
|
}
|
||||||
|
@ -58,9 +61,12 @@ export class CrawlerService {
|
||||||
if(url.length > 10) {
|
if(url.length > 10) {
|
||||||
url = url.substring(0, 10);
|
url = url.substring(0, 10);
|
||||||
}
|
}
|
||||||
|
finalUrls.push(url);
|
||||||
console.log(`Saving file ${path}${url}`);
|
console.log(`Saving file ${path}${url}`);
|
||||||
fs.writeFileSync(`${path}${url}`, content);
|
fs.writeFileSync(`${path}${url}`, content);
|
||||||
});
|
});
|
||||||
|
console.log(`finalUrls: `, finalUrls);
|
||||||
|
return finalUrls;
|
||||||
}
|
}
|
||||||
|
|
||||||
extractDomain(urlString: string) {
|
extractDomain(urlString: string) {
|
||||||
|
|
Loading…
Reference in a new issue