1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "preset": "seo-friendly",
10 "rules": [
11 {
12 "userAgent": "*",
13 "allow": [
14 "/public/",
15 "/blog/",
16 ],
17 "disallow": [
18 "/admin/",
19 "/private/",
20 "/api/",
21 ],
22 "crawlDelay": 2,
23 "comment": "Default rules for all bots",
24 },
25 {
26 "userAgent": "Googlebot",
27 "allow": ["/"],
28 "disallow": [],
29 "comment": "Give Googlebot full access",
30 },
31 ],
32 "sitemaps": ["https://example.com/sitemap.xml"],
33 "host": "",
34 "includeTimestamp": True,
35 "includeGeneratorComment": True,
36 "validateRules": True,
37}
38
39
40run = client.actor("automation-lab/robots-txt-generator").call(run_input=run_input)
41
42
43print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
44for item in client.dataset(run["defaultDatasetId"]).iterate_items():
45 print(item)
46
47