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 "fields": [
11 {
12 "name": "name",
13 "type": "string",
14 "description": "Product name as shown on the page",
15 },
16 {
17 "name": "price",
18 "type": "number",
19 "description": "Current selling price as a plain number",
20 },
21 {
22 "name": "currency",
23 "type": "string",
24 "description": "ISO 4217 currency code of the price, e.g. USD",
25 },
26 {
27 "name": "in_stock",
28 "type": "boolean",
29 "description": "Whether the product can be ordered now",
30 },
31 {
32 "name": "stock",
33 "type": "integer",
34 "description": "Number of items available",
35 },
36 {
37 "name": "upc",
38 "type": "string",
39 "description": "UPC or article number exactly as shown",
40 },
41 {
42 "name": "category",
43 "type": "string",
44 "description": "Product category",
45 },
46 ],
47 "proxyConfiguration": {
48 "useApifyProxy": True,
49 "apifyProxyGroups": ["RESIDENTIAL"],
50 },
51}
52
53
54run = client.actor("tracefetch/ai-web-scraper-verified").call(run_input=run_input)
55
56
57print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
58for item in client.dataset(run.default_dataset_id).iterate_items():
59 print(item)
60
61