1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "preset": "seo-friendly",
12 "sitemaps": [
13 "https://example.com/sitemap.xml"
14 ],
15 "host": "example.com",
16 "rules": [
17 {
18 "userAgents": [
19 "*"
20 ],
21 "allow": [
22 "/"
23 ],
24 "disallow": [
25 "/admin/",
26 "/private/"
27 ],
28 "crawlDelay": 1,
29 "comment": "Default rules for all bots"
30 },
31 {
32 "userAgents": [
33 "Googlebot"
34 ],
35 "allow": [
36 "/"
37 ],
38 "disallow": [],
39 "comment": "Give Googlebot full access"
40 }
41 ],
42 "presetConflictMode": "append",
43 "sites": [
44 {
45 "label": "Marketing site",
46 "preset": "seo-friendly",
47 "sitemaps": [
48 "https://example.com/sitemap.xml"
49 ],
50 "host": "example.com"
51 },
52 {
53 "label": "Staging site",
54 "preset": "staging-private",
55 "sitemaps": [],
56 "host": "staging.example.com"
57 }
58 ],
59 "validateRules": true,
60 "includeTimestamp": true,
61 "includeGeneratorComment": true
62};
63
64
65const run = await client.actor("maximedupre/robots-txt-generator").call(input);
66
67
68console.log('Results from dataset');
69console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
70const { items } = await client.dataset(run.defaultDatasetId).listItems();
71items.forEach((item) => {
72 console.dir(item);
73});
74
75