Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions nodes/MarkdownifyDescription.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
import type { INodeProperties } from 'n8n-workflow';

export const markdownifyOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['markdownify'],
},
},
options: [
{
name: 'Convert',
value: 'convert',
action: 'Convert a webpage or article to clean markdown useful for blogs dev docs and more',
description: 'Convert a webpage or article to clean markdown – useful for blogs, dev docs and more',
},
],
default: 'convert',
},
];
export const markdownifyOperations: INodeProperties[] = [];

export const markdownifyFields: INodeProperties[] = [
{
Expand All @@ -34,7 +13,6 @@ export const markdownifyFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['markdownify'],
operation: ['convert'],
},
},
},
Expand Down
102 changes: 44 additions & 58 deletions nodes/ScrapegraphAI/ScrapegraphAi.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ScrapegraphAi implements INodeType {
icon: 'file:../scrapegraphAI.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
subtitle: '={{$parameter["operation"] ? $parameter["operation"] + ": " + $parameter["resource"] : $parameter["resource"]}}',
description: 'Turn any webpage into usable data in one shot – ScrapegraphAI explores the website and extracts the content you need.',
defaults: {
name: 'ScrapegraphAI',
Expand Down Expand Up @@ -88,8 +88,11 @@ export class ScrapegraphAi implements INodeType {
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;

// Only load operation for resources that still use it
const operation = (resource === 'scrape' || resource === 'agenticscraper')
? this.getNodeParameter('operation', 0) as string
: undefined;

const baseUrl = 'https://api.scrapegraphai.com/v1';

for (let i = 0; i < items.length; i++) {
Expand Down Expand Up @@ -205,64 +208,47 @@ export class ScrapegraphAi implements INodeType {
}

if (resource === 'smartcrawler') {
if (operation === 'crawl') {
const url = this.getNodeParameter('url', i) as string;
const prompt = this.getNodeParameter('prompt', i) as string;
const cacheWebsite = this.getNodeParameter('cacheWebsite', i) as boolean;
const depth = this.getNodeParameter('depth', i) as number;
const maxPages = this.getNodeParameter('maxPages', i) as number;
const sameDomainOnly = this.getNodeParameter('sameDomainOnly', i) as boolean;
const useOutputSchema = this.getNodeParameter('useOutputSchema', i, false) as boolean;
const renderHeavyJs = this.getNodeParameter('renderHeavyJs', i, false) as boolean;

const requestBody: any = {
url: url,
prompt: prompt,
cache_website: cacheWebsite,
depth: depth,
max_pages: maxPages,
same_domain_only: sameDomainOnly,
render_heavy_js: renderHeavyJs,
};

// Add output_schema if enabled and provided
if (useOutputSchema) {
const outputSchema = this.getNodeParameter('outputSchema', i) as string;
try {
requestBody.output_schema = JSON.parse(outputSchema);
} catch (error) {
throw new NodeOperationError(this.getNode(), `Invalid JSON in Output Schema: ${error.message}`);
}
const url = this.getNodeParameter('url', i) as string;
const prompt = this.getNodeParameter('prompt', i) as string;
const cacheWebsite = this.getNodeParameter('cacheWebsite', i) as boolean;
const depth = this.getNodeParameter('depth', i) as number;
const maxPages = this.getNodeParameter('maxPages', i) as number;
const sameDomainOnly = this.getNodeParameter('sameDomainOnly', i) as boolean;
const useOutputSchema = this.getNodeParameter('useOutputSchema', i, false) as boolean;
const renderHeavyJs = this.getNodeParameter('renderHeavyJs', i, false) as boolean;

const requestBody: any = {
url: url,
prompt: prompt,
cache_website: cacheWebsite,
depth: depth,
max_pages: maxPages,
same_domain_only: sameDomainOnly,
render_heavy_js: renderHeavyJs,
};

// Add output_schema if enabled and provided
if (useOutputSchema) {
const outputSchema = this.getNodeParameter('outputSchema', i) as string;
try {
requestBody.output_schema = JSON.parse(outputSchema);
} catch (error) {
throw new NodeOperationError(this.getNode(), `Invalid JSON in Output Schema: ${error.message}`);
}

const response = await this.helpers.httpRequestWithAuthentication.call(this, 'scrapegraphAIApi', {
method: 'POST',
url: `${baseUrl}/crawl`,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: requestBody,
json: true,
});

returnData.push({ json: response, pairedItem: { item: i } });
}

if (operation === 'getStatus') {
const taskId = this.getNodeParameter('taskId', i) as string;

const response = await this.helpers.httpRequestWithAuthentication.call(this, 'scrapegraphAIApi', {
method: 'GET',
url: `${baseUrl}/crawl/${taskId}`,
headers: {
'Accept': 'application/json',
},
json: true,
});

returnData.push({ json: response, pairedItem: { item: i } });
}
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'scrapegraphAIApi', {
method: 'POST',
url: `${baseUrl}/crawl`,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: requestBody,
json: true,
});

returnData.push({ json: response, pairedItem: { item: i } });
}

if (resource === 'markdownify') {
Expand Down
24 changes: 1 addition & 23 deletions nodes/SearchscraperDescription.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
import type { INodeProperties } from 'n8n-workflow';

export const searchscraperOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['searchscraper'],
},
},
options: [
{
name: 'Search',
value: 'search',
action: 'Perform ai powered site wide search and structured data extraction ideal for knowledge retrieval',
description: 'Perform AI-powered site-wide search and structured data extraction – ideal for knowledge retrieval',
},
],
default: 'search',
},
];
export const searchscraperOperations: INodeProperties[] = [];

export const searchscraperFields: INodeProperties[] = [
{
Expand All @@ -34,7 +13,6 @@ export const searchscraperFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['searchscraper'],
operation: ['search'],
},
},
},
Expand Down
52 changes: 1 addition & 51 deletions nodes/SmartcrawlerDescription.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,8 @@
import type { INodeProperties } from 'n8n-workflow';

export const smartcrawlerOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['smartcrawler'],
},
},
options: [
{
name: 'Crawl',
value: 'crawl',
action: 'Give a single URL – the AI crawler follows internal links to extract structured data across multiple pages',
description: 'Give a single URL – the AI crawler follows internal links to extract structured data across multiple pages',
},
{
name: 'Get Status',
value: 'getStatus',
action: 'Get the status and results of a crawl job using its task ID',
description: 'Get the status and results of a crawl job using its task ID',
},
],
default: 'crawl',
},
];
export const smartcrawlerOperations: INodeProperties[] = [];

export const smartcrawlerFields: INodeProperties[] = [
{
displayName: 'Task ID',
name: 'taskId',
type: 'string',
required: true,
default: '',
description: 'The task ID returned from a crawl operation',
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['getStatus'],
},
},
},
{
displayName: 'URL',
name: 'url',
Expand All @@ -54,7 +13,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand All @@ -68,7 +26,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand All @@ -81,7 +38,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand All @@ -94,7 +50,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand All @@ -107,7 +62,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand All @@ -120,7 +74,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand All @@ -133,7 +86,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand All @@ -147,7 +99,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
useOutputSchema: [true],
},
},
Expand All @@ -161,7 +112,6 @@ export const smartcrawlerFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartcrawler'],
operation: ['crawl'],
},
},
},
Expand Down
25 changes: 1 addition & 24 deletions nodes/SmartscraperDescription.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
import type { INodeProperties } from 'n8n-workflow';

export const smartscraperOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['smartscraper'],
},
},
options: [
{
name: 'Scrape',
value: 'scrape',
action: 'Autonomously extract live data from any website perfect for e commerce job boards lead capture and more',
description: 'Autonomously extract live data from any website – perfect for e-commerce, job boards, lead capture and more',
},
],
default: 'scrape',
},
];
export const smartscraperOperations: INodeProperties[] = [];

export const smartscraperFields: INodeProperties[] = [
{
Expand All @@ -34,7 +13,6 @@ export const smartscraperFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartscraper'],
operation: ['scrape'],
},
},
},
Expand All @@ -48,7 +26,6 @@ export const smartscraperFields: INodeProperties[] = [
displayOptions: {
show: {
resource: ['smartscraper'],
operation: ['scrape'],
},
},
},
Expand Down