1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "fixtures": [
10 {
11 "id": "001-rename",
12 "baselineHtml": "<article><span class=\"price\">$10</span></article>",
13 "currentHtml": "<article><span class=\"price-new\">$10</span></article>",
14 },
15 {
16 "id": "002-attribute",
17 "baselineHtml": "<span class=\"offer\" data-price=\"\"></span>",
18 "currentHtml": "<span class=\"offer\">$10</span>",
19 },
20 {
21 "id": "003-duplicate",
22 "baselineHtml": "<span class=\"price\">$10</span>",
23 "currentHtml": "<span class=\"price\">$10</span><span class=\"price\">$10</span>",
24 },
25 {
26 "id": "004-natural",
27 "baselineHtml": "<h1>Blue shoe</h1>",
28 "currentHtml": "<h1>New blue shoe</h1>",
29 },
30 ],
31 "rules": [
32 {
33 "id": "price-selector",
34 "selector": ".price",
35 "mode": "text",
36 "whitespace": "trim",
37 "minMatches": 1,
38 "maxMatches": 1,
39 "fixtureIds": ["001-rename"],
40 },
41 {
42 "id": "price-attribute",
43 "selector": ".offer",
44 "mode": "attribute",
45 "attribute": "data-price",
46 "whitespace": "preserve",
47 "minMatches": 1,
48 "maxMatches": 1,
49 "fixtureIds": ["002-attribute"],
50 },
51 {
52 "id": "one-price",
53 "selector": ".price",
54 "mode": "text",
55 "whitespace": "collapse",
56 "minMatches": 1,
57 "maxMatches": 1,
58 "expectedValues": ["$10"],
59 "fixtureIds": ["003-duplicate"],
60 },
61 {
62 "id": "title",
63 "selector": "h1",
64 "mode": "text",
65 "whitespace": "collapse",
66 "minMatches": 1,
67 "maxMatches": 1,
68 "fixtureIds": ["004-natural"],
69 },
70 ],
71}
72
73
74run = client.actor("h_murdock/html-selector-fixture-audit").call(run_input=run_input)
75
76
77print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
78for item in client.dataset(run.default_dataset_id).iterate_items():
79 print(item)
80
81