-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
29 lines (25 loc) · 921 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { MessageType, Scraper, ScraperConfiguration } from "./scrapers";
import { colorError, colorQuery, colorWarning } from "./utils";
export * as xml from "./xml"
export * as utils from "./utils"
export function consoleMessagehandler(message: string, type: MessageType) {
if(type == "error") {
console.error(colorError(message));
} else if(type == "warning") {
console.warn(colorWarning(message));
} else {
console.info(message);
}
}
export const defaultConfiguration: ScraperConfiguration = {
messageHandler: consoleMessagehandler,
itemHandler: (item) => {
item.scraper.info(colorQuery(`created new item $${item.index}`));
},
entryHandler: (entry) => {
entry.scraper.info(colorQuery(`$${entry.item.index}/${entry.path} = "${entry.value}"`));
},
runHandler: (handler, input) => handler(input),
urlValidator: null,
};
export let scraper = new Scraper(defaultConfiguration);