1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "selectors": [
12 "table table tr[class='athing'] td:nth-child(3) > span > a"
13 ],
14 "scrapers": `// (input) => ({
15 // title: {
16 // selectors: ["table table tr[class='athing'] td:nth-child(3) > span > a"],
17 // extractor: node => node.innerText,
18 // },
19 // links: {
20 // contents: {
21 // selectors: ["table table tr[class='athing'] td:nth-child(3) > span > a"],
22 // extractor: node => node.href,
23 // },
24 // comments: {
25 // selectors: ["table table tr td[class='subtext'] span a[href^=item]:first-child"],
26 // extractor: node => node.href,
27 // },
28 // },
29 // })`,
30 "limits.alerts": 10,
31 "limits.results": 100,
32 "filters": `// [
33 // ({title}) => title.length > 1, // absolute
34 // ({links}) => links.contents.includes('http'), // absolute
35 // ({price}, {price: oldPrice}) => price < oldPrice, // relative
36 // ]`,
37 "matcher": `// ({exclude, include}) => ({include}) // ignore fields in comparison with records
38 // ({price, ...match}) => match // e.g. ignore dynamic field "price" from matching`,
39 "pages.retries": 3,
40 "hooks.load": `// async page => {
41 // await page.click('button[name="cookie-consent"]').catch(error => null);
42 // }`,
43 "proxy": {
44 "useApifyProxy": false
45 }
46};
47
48
49const run = await client.actor("cyberfly/listingmonitor").call(input);
50
51
52console.log('Results from dataset');
53console.log(`πΎ Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
54const { items } = await client.dataset(run.defaultDatasetId).listItems();
55items.forEach((item) => {
56 console.dir(item);
57});
58
59