1
2
3
4const Apify = require('apify');
5
6Apify.main(async () => {
7
8
9 const input = await Apify.getInput();
10 console.log('Input:');
11 console.dir(input);
12
13
14
15 const metamorphInput = {
16 "breakpointLocation": "NONE",
17 "browserLog": false,
18 "debugLog": false,
19 "downloadCss": true,
20 "downloadMedia": true,
21 "ignoreCorsAndCsp": false,
22 "ignoreSslErrors": false,
23 "injectJQuery": true,
24 "keepUrlFragments": false,
25 "maxRequestRetries": input.maxRequestRetries,
26 "pageFunction": input.pageFunction,
27 "postNavigationHooks": `// We need to return array of (possibly async) functions here.
28 // The functions accept a single argument: the "crawlingContext" object.
29 [
30 async (crawlingContext) => {
31 // ...
32 },
33 ]`,
34 "preNavigationHooks": `// We need to return array of (possibly async) functions here.
35 // The functions accept two arguments: the "crawlingContext" object
36 // and "gotoOptions".
37 [
38 async (crawlingContext, gotoOptions) => {
39 // ...
40 },
41 ]`,
42 "proxyConfiguration": {
43 "useApifyProxy": true,
44 "apifyProxyCountry": "US"
45 },
46 "runMode": "PRODUCTION",
47 "startUrls": input.startUrls,
48 "useChrome": true,
49 "waitUntil": [
50 "networkidle2"
51 ]
52 };
53
54
55 await Apify.metamorph('apify/web-scraper', metamorphInput);
56});