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 "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
14 }
15 ],
16 "schema": {
17 "type": "object",
18 "properties": {
19 "title": {
20 "type": "string"
21 },
22 "price": {
23 "type": "number"
24 },
25 "in_stock": {
26 "type": "boolean"
27 },
28 "description": {
29 "type": "string"
30 }
31 }
32 }
33};
34
35
36const run = await client.actor("itsoul/ai-structured-extractor").call(input);
37
38
39console.log('Results from dataset');
40console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
41const { items } = await client.dataset(run.defaultDatasetId).listItems();
42items.forEach((item) => {
43 console.dir(item);
44});
45
46