1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6    token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11    "startUrls": [
12        {
13            "key": "START",
14            "value": "https://www.example.com/"
15        }
16    ],
17    "crawlPurls": [
18        {
19            "key": "MY_LABEL",
20            "value": "https://www.example.com/[.*]"
21        }
22    ],
23    "clickableElementsSelector": "a:not([rel=nofollow])",
24    "pageFunction": function pageFunction(context) {
25        
26        var $ = context.jQuery;
27        var result = {
28            title: $('title').text(),
29            myValue: $('TODO').text()
30        };
31        return result;
32    },
33    "interceptRequest": function interceptRequest(context, newRequest) {
34        
35        
36        return newRequest;
37    }
38};
39
40
41const run = await client.actor("apify/legacy-phantomjs-crawler").call(input);
42
43
44console.log('Results from dataset');
45console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
46const { items } = await client.dataset(run.defaultDatasetId).listItems();
47items.forEach((item) => {
48    console.dir(item);
49});
50
51