1
2import { Actor } from 'apify';
3
4import { CheerioCrawler, Dataset } from 'crawlee';
5
6
7
8
9
10await Actor.init();
11
12
13const {
14 startUrls = ['https://crawlee.dev'],
15 maxRequestsPerCrawl = 100,
16} = await Actor.getInput() ?? {};
17
18const proxyConfiguration = await Actor.createProxyConfiguration();
19
20const crawler = new CheerioCrawler({
21 proxyConfiguration,
22 maxRequestsPerCrawl,
23 async requestHandler({ enqueueLinks, request, $, log }) {
24 log.info('enqueueing new URLs');
25 await enqueueLinks();
26
27
28 const title = $('title').text();
29 log.info(`${title}`, { url: request.loadedUrl });
30
31
32 await Dataset.pushData({ url: request.loadedUrl, title });
33 },
34});
35
36await crawler.run(startUrls);
37
38
39await Actor.exit();