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://apify.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 "proxyConfiguration": {
25 "useApifyProxy": true
26 },
27 "pageFunction": function pageFunction(context) {
28
29 var $ = context.jQuery;
30 var result = {
31 title: $('title').text(),
32 myValue: $('TODO').text()
33 };
34 return result;
35 },
36 "interceptRequest": function interceptRequest(context, newRequest) {
37
38
39 return newRequest;
40 }
41};
42
43
44const run = await client.actor("barry8schneider/legacy-phantomjs-crawler").call(input);
45
46
47console.log('Results from dataset');
48console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
49const { items } = await client.dataset(run.defaultDatasetId).listItems();
50items.forEach((item) => {
51 console.dir(item);
52});
53
54