1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "mappings": [
10 {
11 "id": "001",
12 "sourceUrl": "https://example.com/Old?campaign=Q3#section",
13 "expectedFinalUrl": "https://example.com/New/?campaign=Q3",
14 },
15 {
16 "id": "002",
17 "sourceUrl": "https://example.com/legacy",
18 "expectedFinalUrl": "https://example.com/current",
19 },
20 {
21 "id": "003",
22 "sourceUrl": "https://example.com/sale-old",
23 "expectedFinalUrl": "https://example.com/sale-new",
24 },
25 {
26 "id": "004",
27 "sourceUrl": "https://example.com/retired",
28 "expectedFinalUrl": "https://example.com/retired",
29 "expectedFinalStatus": 410,
30 },
31 {
32 "id": "005",
33 "sourceUrl": "https://example.com/loop-a",
34 "expectedFinalUrl": "https://example.com/loop-final",
35 },
36 {
37 "id": "006",
38 "sourceUrl": "https://example.com/unreachable",
39 "expectedFinalUrl": "https://example.com/available",
40 },
41 {
42 "id": "007",
43 "sourceUrl": "https://example.com/missing",
44 "expectedFinalUrl": "https://example.com/missing",
45 },
46 ],
47 "traces": [
48 {
49 "mappingId": "001",
50 "steps": [
51 {
52 "url": "https://example.com/Old?campaign=Q3",
53 "status": 301,
54 "location": "/New/?campaign=Q3",
55 },
56 {
57 "url": "https://example.com/New/?campaign=Q3",
58 "status": 200,
59 },
60 ],
61 },
62 {
63 "mappingId": "002",
64 "steps": [
65 {
66 "url": "https://example.com/legacy",
67 "status": 308,
68 "location": "/current",
69 },
70 {
71 "url": "https://example.com/current",
72 "status": 200,
73 },
74 ],
75 },
76 {
77 "mappingId": "003",
78 "steps": [
79 {
80 "url": "https://example.com/sale-old",
81 "status": 302,
82 "location": "/home",
83 },
84 {
85 "url": "https://example.com/home",
86 "status": 200,
87 },
88 ],
89 },
90 {
91 "mappingId": "004",
92 "steps": [{
93 "url": "https://example.com/retired",
94 "status": 410,
95 }],
96 },
97 {
98 "mappingId": "005",
99 "steps": [
100 {
101 "url": "https://example.com/loop-a",
102 "status": 301,
103 "location": "/loop-b",
104 },
105 {
106 "url": "https://example.com/loop-b",
107 "status": 301,
108 "location": "/loop-a",
109 },
110 ],
111 },
112 {
113 "mappingId": "006",
114 "steps": [],
115 "failure": "transport_error",
116 },
117 {
118 "mappingId": "007",
119 "steps": [{
120 "url": "https://example.com/missing",
121 "status": 404,
122 }],
123 },
124 ],
125}
126
127
128run = client.actor("h_murdock/redirect-release-qa").call(run_input=run_input)
129
130
131print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
132for item in client.dataset(run.default_dataset_id).iterate_items():
133 print(item)
134
135