1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "urls": ["https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"],
10 "schema": {
11 "type": "object",
12 "properties": {
13 "title": {
14 "type": "string",
15 "description": "Book title",
16 },
17 "price": {
18 "type": [
19 "number",
20 "null",
21 ],
22 "description": "Price as a number, without currency symbol",
23 },
24 "currency": {
25 "type": [
26 "string",
27 "null",
28 ],
29 "description": "ISO currency code or symbol",
30 },
31 "in_stock": {
32 "type": [
33 "boolean",
34 "null",
35 ],
36 "description": "True if the book is in stock",
37 },
38 "rating_stars": {
39 "type": [
40 "integer",
41 "null",
42 ],
43 "minimum": 1,
44 "maximum": 5,
45 },
46 },
47 "required": [
48 "title",
49 "price",
50 ],
51 "additionalProperties": False,
52 },
53 "instructions": "",
54 "maxItems": 5,
55 "proxyConfiguration": { "useApifyProxy": True },
56}
57
58
59run = client.actor("tiger19935/schema-ai-extractor").call(run_input=run_input)
60
61
62print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
63for item in client.dataset(run.default_dataset_id).iterate_items():
64 print(item)
65
66