-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathusage.ts
More file actions
25 lines (20 loc) · 785 Bytes
/
usage.ts
File metadata and controls
25 lines (20 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { CheerioCrawler, Configuration } from 'crawlee';
import { WinstonAdapter, winstonLogger } from './implementation';
// Wrap your Winston logger in the adapter and pass it to Configuration
const config = new Configuration({
loggerProvider: new WinstonAdapter(winstonLogger),
});
const crawler = new CheerioCrawler(
{
async requestHandler({ request, $, log }) {
// `log` here is the per-crawler scoped CrawleeLogger instance
// backed by your Winston adapter.
log.info(`Processing ${request.url}`);
const title = $('title').text();
log.debug('Page title extracted', { title });
console.log(`Title: ${title}`);
},
},
config,
);
await crawler.run(['https://crawlee.dev']);