n8n-nodes-crawl4ai
Version:
n8n nodes for Crawl4AI web crawler and data extraction
112 lines (111 loc) • 2.64 kB
TypeScript
import { IDataObject } from 'n8n-workflow';
export interface Crawl4aiApiCredentials {
connectionMode: 'direct' | 'docker';
dockerUrl?: string;
authenticationType?: 'none' | 'token' | 'basic';
apiToken?: string;
username?: string;
password?: string;
enableLlm?: boolean;
llmProvider?: string;
apiKey?: string;
ollamaUrl?: string;
customProvider?: string;
customApiKey?: string;
cacheDir?: string;
}
export interface Crawl4aiNodeOptions extends IDataObject {
bypassCache?: boolean;
includeMedia?: boolean;
verboseResponse?: boolean;
cacheMode?: 'enabled' | 'bypass' | 'only';
}
export interface BrowserConfig {
headless?: boolean;
javaScriptEnabled?: boolean;
viewport?: {
width: number;
height: number;
};
timeout?: number;
userAgent?: string;
}
export interface CrawlerRunConfig {
cacheMode?: 'enabled' | 'bypass' | 'only';
streamEnabled?: boolean;
pageTimeout?: number;
requestTimeout?: number;
jsCode?: string | string[];
jsOnly?: boolean;
cssSelector?: string;
excludedTags?: string[];
excludeExternalLinks?: boolean;
checkRobotsTxt?: boolean;
wordCountThreshold?: number;
sessionId?: string;
maxRetries?: number;
viewport?: {
width: number;
height: number;
};
headless?: boolean;
javaScriptEnabled?: boolean;
timeout?: number;
userAgent?: string;
extractionStrategy?: any;
}
export interface CrawlResult {
url: string;
success: boolean;
statusCode?: number;
title?: string;
markdown?: string;
html?: string;
cleaned_html?: string;
text?: string;
links?: {
internal: Link[];
external: Link[];
};
media?: {
images: Media[];
videos: Media[];
};
extracted_content?: string;
error_message?: string;
crawl_time?: number;
metadata?: Record<string, any>;
}
export interface Link {
href: string;
text: string;
title?: string;
}
export interface Media {
src: string;
alt?: string;
title?: string;
type?: string;
}
export interface CssSelectorField {
name: string;
selector: string;
type: 'text' | 'attribute' | 'html';
attribute?: string;
}
export interface CssSelectorSchema {
name: string;
baseSelector: string;
fields: CssSelectorField[];
}
export interface LlmSchemaField {
name: string;
type: string;
description?: string;
}
export interface LlmSchema {
title?: string;
type: 'object';
properties: Record<string, LlmSchemaField>;
required?: string[];
}