1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "monitorId": "my-price-monitor",
12 "targets": [
13 {
14 "id": "a-light-in-the-attic",
15 "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
16 "fields": [
17 {
18 "name": "title",
19 "selector": "h1",
20 "type": "text"
21 },
22 {
23 "name": "price",
24 "selector": ".price_color",
25 "type": "price",
26 "currency": "GBP",
27 "decimalSeparator": "."
28 },
29 {
30 "name": "availability",
31 "selector": ".availability",
32 "type": "text"
33 }
34 ]
35 }
36 ]
37};
38
39
40const run = await client.actor("telvio/ai-change-monitor").call(input);
41
42
43console.log('Results from dataset');
44console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
45const { items } = await client.dataset(run.defaultDatasetId).listItems();
46items.forEach((item) => {
47 console.dir(item);
48});
49
50