1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "startUrls": [{ "url": "https://books.toscrape.com/" }],
10 "recordSelector": "article.product_pod",
11 "fields": [
12 {
13 "name": "title",
14 "selector": "h3 a",
15 "source": "attribute",
16 "attribute": "title",
17 "type": "string",
18 "required": True,
19 },
20 {
21 "name": "price",
22 "selector": ".price_color",
23 "type": "number",
24 "pattern": "([0-9.]+)",
25 "required": True,
26 },
27 {
28 "name": "productUrl",
29 "selector": "h3 a",
30 "source": "attribute",
31 "attribute": "href",
32 "type": "url",
33 "required": True,
34 },
35 ],
36 "maxItems": 20,
37}
38
39
40run = client.actor("automation-lab/schema-guided-web-data-to-excel").call(run_input=run_input)
41
42
43print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
44for item in client.dataset(run.default_dataset_id).iterate_items():
45 print(item)
46
47