1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "redirectMap": `[
12 {
13 "label": "W3C homepage HTTP to HTTPS",
14 "source": "http://www.w3.org/",
15 "destination": "https://www.w3.org/",
16 "status": 200,
17 "maxHops": 3,
18 "titleContains": "W3C",
19 "noindex": false,
20 "forbidSoft404": true
21 },
22 {
23 "label": "IANA example-domains guide",
24 "source": "https://www.iana.org/help/example-domains",
25 "destination": "https://www.iana.org/help/example-domains",
26 "status": 200,
27 "maxHops": 2,
28 "titleContains": "Example Domains",
29 "h1Contains": "Example Domains",
30 "noindex": false,
31 "forbidSoft404": true
32 },
33 {
34 "label": "Missing purchase CTA",
35 "source": "https://www.iana.org/help/example-domains",
36 "destination": "https://www.iana.org/help/example-domains",
37 "status": 200,
38 "titleContains": "Example Domains",
39 "requiredText": "Add to cart"
40 },
41 {
42 "label": "Old path collapsed to homepage",
43 "source": "https://httpbin.org/redirect-to?url=https://www.w3.org/&status_code=301",
44 "destination": "https://www.w3.org/TR/webarch/",
45 "status": 200,
46 "maxHops": 5
47 },
48 {
49 "label": "Redirect chain over hop budget",
50 "source": "https://httpbin.org/redirect/2",
51 "destination": "https://httpbin.org/get",
52 "status": 200,
53 "maxHops": 1
54 },
55 {
56 "label": "German market expected",
57 "source": "https://www.iana.org/help/example-domains",
58 "status": 200,
59 "region": "de",
60 "hreflang": "de-DE"
61 }
62]`,
63 "patternAssertions": [
64 {
65 "pattern": "https://www.iana.org/help/*",
66 "forbidSoft404": true,
67 "noindex": false
68 }
69 ],
70 "monitorId": "sample"
71};
72
73
74const run = await client.actor("plusonets/site-migration-regression-auditor").call(input);
75
76
77console.log('Results from dataset');
78console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
79const { items } = await client.dataset(run.defaultDatasetId).listItems();
80items.forEach((item) => {
81 console.dir(item);
82});
83
84