1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "pages": [
12 {
13 "id": "001",
14 "url": "https://example.com/en",
15 "status": 200,
16 "canonical": "https://example.com/en",
17 "alternates": [
18 {
19 "language": "en-GB",
20 "url": "https://example.com/en",
21 "source": "html:head/link[1]"
22 },
23 {
24 "language": "de",
25 "url": "https://example.de/de",
26 "source": "html:head/link[2]"
27 },
28 {
29 "language": "zh-Hans",
30 "url": "https://example.com/zh",
31 "source": "html:head/link[3]"
32 }
33 ]
34 },
35 {
36 "id": "002",
37 "url": "https://example.de/de",
38 "status": 200,
39 "canonical": "https://example.de/de",
40 "alternates": [
41 {
42 "language": "EN-GB",
43 "url": "https://example.com/en",
44 "source": "html:head/link[1]"
45 },
46 {
47 "language": "DE",
48 "url": "https://example.de/de",
49 "source": "html:head/link[2]"
50 },
51 {
52 "language": "ZH-HANS",
53 "url": "https://example.com/zh",
54 "source": "html:head/link[3]"
55 }
56 ]
57 },
58 {
59 "id": "003",
60 "url": "https://example.com/zh",
61 "status": 200,
62 "canonical": "https://example.com/zh",
63 "alternates": [
64 {
65 "language": "en-GB",
66 "url": "https://example.com/en",
67 "source": "html:head/link[1]"
68 },
69 {
70 "language": "de",
71 "url": "https://example.de/de",
72 "source": "html:head/link[2]"
73 },
74 {
75 "language": "zh-Hans",
76 "url": "https://example.com/zh",
77 "source": "html:head/link[3]"
78 }
79 ]
80 },
81 {
82 "id": "004",
83 "url": "https://shop.example.com/en/item",
84 "status": 200,
85 "alternates": [
86 {
87 "language": "en",
88 "url": "https://shop.example.com/en/item"
89 },
90 {
91 "language": "fr",
92 "url": "https://shop.example.fr/fr/item"
93 }
94 ]
95 },
96 {
97 "id": "005",
98 "url": "https://shop.example.fr/fr/item",
99 "status": 200,
100 "alternates": [
101 {
102 "language": "fr",
103 "url": "https://shop.example.fr/fr/item"
104 }
105 ]
106 },
107 {
108 "id": "006",
109 "url": "https://example.org/catalog",
110 "alternates": [
111 {
112 "language": "en",
113 "url": "https://example.org/catalog"
114 },
115 {
116 "language": "de",
117 "url": "https://example.org/de/catalog"
118 },
119 {
120 "language": "zh-Hans",
121 "url": "/zh/catalog"
122 }
123 ]
124 }
125 ]
126};
127
128
129const run = await client.actor("h_murdock/hreflang-cluster-audit").call(input);
130
131
132console.log('Results from dataset');
133console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
134const { items } = await client.dataset(run.defaultDatasetId).listItems();
135items.forEach((item) => {
136 console.dir(item);
137});
138
139