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 "rules": [
13 {
14 "userAgent": "*",
15 "allow": [
16 "/public/",
17 "/blog/"
18 ],
19 "disallow": [
20 "/admin/",
21 "/private/",
22 "/api/"
23 ],
24 "crawlDelay": 2,
25 "comment": "Default rules for all bots"
26 },
27 {
28 "userAgent": "Googlebot",
29 "allow": [
30 "/"
31 ],
32 "disallow": [],
33 "comment": "Give Googlebot full access"
34 }
35 ],
36 "sitemaps": [
37 "https://example.com/sitemap.xml"
38 ],
39 "host": "",
40 "includeTimestamp": true,
41 "includeGeneratorComment": true,
42 "validateRules": true
43};
44
45
46const run = await client.actor("automation-lab/robots-txt-generator").call(input);
47
48
49console.log('Results from dataset');
50console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
51const { items } = await client.dataset(run.defaultDatasetId).listItems();
52items.forEach((item) => {
53 console.dir(item);
54});
55
56