1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "texts": [
12 "<h1> Stellar Gooseneck Kettle 1.0L </h1><span class=\"price\">$49.99</span> In stock"
13 ],
14 "outputSchema": {
15 "type": "object",
16 "properties": {
17 "name": {
18 "type": "string"
19 },
20 "price": {
21 "type": [
22 "number",
23 "null"
24 ]
25 },
26 "currency": {
27 "type": [
28 "string",
29 "null"
30 ],
31 "description": "ISO 4217 code, e.g. USD"
32 },
33 "in_stock": {
34 "type": [
35 "boolean",
36 "null"
37 ]
38 }
39 },
40 "required": [
41 "name",
42 "price",
43 "currency",
44 "in_stock"
45 ]
46 }
47};
48
49
50const run = await client.actor("sprucethedata/clean-json").call(input);
51
52
53console.log('Results from dataset');
54console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
55const { items } = await client.dataset(run.defaultDatasetId).listItems();
56items.forEach((item) => {
57 console.dir(item);
58});
59
60