Skip to content

Commit d7da40f

Browse files
added warnings for cheerio
1 parent bd45bc1 commit d7da40f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/main.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const Apify = require('apify');
22
const cheerio = require('cheerio');
33

4+
const { log } = Apify.utils;
5+
46
const { testHtml } = require('./checkers.js');
57
const { toSimpleState } = require('./utils.js');
68
const { GOOGLE_BOT_HEADERS } = require('./constants.js');
@@ -27,8 +29,21 @@ Apify.main(async () => {
2729
useGoogleBotHeaders = false,
2830
} = input;
2931

32+
if (type === 'cheerio') {
33+
log.info('Running a Cheerio Crawler. Cheerio downloads only initial HTML. If you need to render JavaScript or wait on a page for data to load, choose Puppeteer as Type of Crawler.');
34+
if (waitFor) {
35+
log.warning(`waitFor parameter doesn't work in Cheerio. If you need to wait, please choose Puppeteer as Type of Crawler.`);
36+
}
37+
if (headfull) {
38+
log.warning(`headfull parameter doesn't work in Cheerio. If you need to use headfull browser, please choose Puppeteer as Type of Crawler.`);
39+
}
40+
if (useChrome) {
41+
log.warning(`useChrome parameter doesn't work in Cheerio. If you need to use Chrome browser, please choose Puppeteer as Type of Crawler.`);
42+
}
43+
}
44+
3045
const proxyUrl = proxyConfiguration.useApifyProxy
31-
? Apify.getApifyProxyUrl({ groups: proxyConfiguration.apifyProxyGroups, country: proxyConfiguration.apifyProxyCountry})
46+
? Apify.getApifyProxyUrl({ groups: proxyConfiguration.apifyProxyGroups, country: proxyConfiguration.apifyProxyCountry })
3247
: null;
3348

3449
const defaultState = {
@@ -51,7 +66,7 @@ Apify.main(async () => {
5166
}, 10000);
5267

5368
setInterval(() => {
54-
console.dir(toSimpleState(state))
69+
console.dir(toSimpleState(state));
5570
}, 10000);
5671

5772
const requestQueue = await Apify.openRequestQueue();

0 commit comments

Comments
 (0)