Compare commits
No commits in common. "a5799e4b48c5ca86274aa1589568e9bb879fd553" and "6d3ed58526a3476543b3d6024ca19ab3c600f7a8" have entirely different histories.
a5799e4b48
...
6d3ed58526
5 changed files with 4 additions and 22 deletions
|
@ -1,16 +1,11 @@
|
|||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
import { CrawlerService } from '../crawler/crawler.service';
|
||||
import { DbService } from '../db/db.service';
|
||||
|
||||
@Controller('/')
|
||||
export class ApiController {
|
||||
constructor(private crawlerService: CrawlerService, private DbService: DbService) {}
|
||||
constructor(private crawlerService: CrawlerService) {}
|
||||
@Post('crawl')
|
||||
async crawl(@Body() body: { url: string }) {
|
||||
const results = this.crawlerService.crawl(body.url);
|
||||
results.then((data) => {
|
||||
console.log(data)
|
||||
this.DbService.insert(data, 'crawler');
|
||||
});
|
||||
return this.crawlerService.crawl(body.url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { ApiController } from './api.controller';
|
||||
import { CrawlerService } from '../crawler/crawler.service';
|
||||
import { DbService } from '../db/db.service';
|
||||
|
||||
@Module({
|
||||
controllers: [ApiController],
|
||||
providers: [CrawlerService, DbService]
|
||||
providers: [CrawlerService]
|
||||
|
||||
})
|
||||
export class ApiModule {}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { ApiModule } from './api/api.module';
|
||||
import { CrawlerModule } from './crawler/crawler.module';
|
||||
import { DbModule } from './db/db.module';
|
||||
|
||||
@Module({
|
||||
imports: [ApiModule, CrawlerModule, DbModule]
|
||||
imports: [ApiModule, CrawlerModule]
|
||||
})
|
||||
export class AppModule {}
|
||||
|
|
|
@ -42,10 +42,6 @@ export class CrawlerService {
|
|||
// URLS //
|
||||
const urls = await page.$$eval('a', links => links.map(link => link.href));
|
||||
await browser.close();
|
||||
return {
|
||||
cssSheetsLocation,
|
||||
scriptsSheetsLocation
|
||||
}
|
||||
}
|
||||
|
||||
async downloadFiles(urls: string[], path: string) {
|
||||
|
|
|
@ -5,11 +5,4 @@ export class DbService {
|
|||
constructor() {
|
||||
console.log(`DbService constructor`);
|
||||
}
|
||||
|
||||
insert(data: {
|
||||
cssSheetsLocation: string[];
|
||||
scriptsSheetsLocation: string[];
|
||||
}, collection: string) {
|
||||
console.log({data, collection});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue