MCPcopy
hub / github.com/BuilderIO/gpt-crawler / handler

Function handler

src/cli.ts:20–81  ·  view source on GitHub ↗
(options: Config)

Source from the content-addressed store, hash-verified

18};
19
20async function handler(options: Config) {
21 try {
22 const {
23 url,
24 match,
25 selector,
26 maxPagesToCrawl: maxPagesToCrawlStr,
27 outputFileName,
28 } = options;
29
30 // @ts-ignore
31 const maxPagesToCrawl = parseInt(maxPagesToCrawlStr, 10);
32
33 let config: Config = {
34 url,
35 match,
36 selector,
37 maxPagesToCrawl,
38 outputFileName,
39 };
40
41 if (!config.url || !config.match || !config.selector) {
42 const questions = [];
43
44 if (!config.url) {
45 questions.push({
46 type: "input",
47 name: "url",
48 message: messages.url,
49 });
50 }
51
52 if (!config.match) {
53 questions.push({
54 type: "input",
55 name: "match",
56 message: messages.match,
57 });
58 }
59
60 if (!config.selector) {
61 questions.push({
62 type: "input",
63 name: "selector",
64 message: messages.selector,
65 });
66 }
67
68 const answers = await inquirer.prompt(questions);
69
70 config = {
71 ...config,
72 ...answers,
73 };
74 }
75
76 await crawl(config);
77 await write(config);

Callers

nothing calls this directly

Calls 2

crawlFunction · 0.85
writeFunction · 0.85

Tested by

no test coverage detected