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 //
|
||||
const stylesheetsUrls = await page.$$eval('link[rel="stylesheet"]', links => links.map(link => link.href));
|
||||
let cssDir = `${directory}/css/`
|
||||
await this.downloadFiles(stylesheetsUrls, cssDir);
|
||||
const cssSheetsLocation = await this.downloadFiles(stylesheetsUrls, cssDir);
|
||||
console.log(`cssSheetsLocation: `, cssSheetsLocation);
|
||||
// STYLESHEETS //
|
||||
|
||||
// SCRIPTS //
|
||||
const scriptsUrls = await page.$$eval('script', scripts => scripts.map(script => script.src));
|
||||
let scriptsDir = `${directory}/scripts/`
|
||||
await this.downloadFiles(scriptsUrls, scriptsDir);
|
||||
const scriptsSheetsLocation = await this.downloadFiles(scriptsUrls, scriptsDir);
|
||||
console.log(`scriptsSheetsLocation: `, scriptsSheetsLocation)
|
||||
// SCRIPTS //
|
||||
|
||||
// SCREENSHOT //
|
||||
|
@ -42,6 +44,7 @@ export class CrawlerService {
|
|||
}
|
||||
|
||||
async downloadFiles(urls: string[], path: string) {
|
||||
const finalUrls = [];
|
||||
if (!fs.existsSync(path)) {
|
||||
mkdirSync(path);
|
||||
}
|
||||
|
@ -58,9 +61,12 @@ export class CrawlerService {
|
|||
if(url.length > 10) {
|
||||
url = url.substring(0, 10);
|
||||
}
|
||||
finalUrls.push(url);
|
||||
console.log(`Saving file ${path}${url}`);
|
||||
fs.writeFileSync(`${path}${url}`, content);
|
||||
});
|
||||
console.log(`finalUrls: `, finalUrls);
|
||||
return finalUrls;
|
||||
}
|
||||
|
||||
extractDomain(urlString: string) {
|
||||
|
|
Loading…
Reference in a new issue