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