1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "urls": [
12 "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
13 ],
14 "fields": [
15 {
16 "name": "name",
17 "type": "string",
18 "description": "Product name as shown on the page"
19 },
20 {
21 "name": "price",
22 "type": "number",
23 "description": "Current selling price as a plain number"
24 },
25 {
26 "name": "currency",
27 "type": "string",
28 "description": "ISO 4217 currency code of the price, e.g. USD"
29 },
30 {
31 "name": "in_stock",
32 "type": "boolean",
33 "description": "Whether the product can be ordered now"
34 },
35 {
36 "name": "stock",
37 "type": "integer",
38 "description": "Number of items available"
39 },
40 {
41 "name": "upc",
42 "type": "string",
43 "description": "UPC or article number exactly as shown"
44 },
45 {
46 "name": "category",
47 "type": "string",
48 "description": "Product category"
49 }
50 ],
51 "proxyConfiguration": {
52 "useApifyProxy": true,
53 "apifyProxyGroups": [
54 "RESIDENTIAL"
55 ]
56 }
57};
58
59
60const run = await client.actor("tracefetch/ai-web-scraper-verified").call(input);
61
62
63console.log('Results from dataset');
64console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
65const { items } = await client.dataset(run.defaultDatasetId).listItems();
66items.forEach((item) => {
67 console.dir(item);
68});
69
70