Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
93 changes: 93 additions & 0 deletions nodes/AgenticscraperDescription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import type { INodeProperties } from 'n8n-workflow';

export const agenticscraperOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['agenticscraper'],
},
},
options: [
{
name: 'Automate',
value: 'automate',
action: 'AI-powered browser automation with custom steps • 15 credits per request',
description: 'AI-powered browser automation with custom steps • 15 credits per request',
},
],
default: 'automate',
},
];

export const agenticscraperFields: INodeProperties[] = [
{
displayName: 'URL',
name: 'url',
type: 'string',
required: true,
default: '',
description: 'URL of the website to interact with',
displayOptions: {
show: {
resource: ['agenticscraper'],
operation: ['automate'],
},
},
},
{
displayName: 'Use Session',
name: 'useSession',
type: 'boolean',
default: true,
description: 'Whether to maintain session state across interactions',
displayOptions: {
show: {
resource: ['agenticscraper'],
operation: ['automate'],
},
},
},
{
displayName: 'Steps',
name: 'steps',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {
stepItems: [
{
step: '',
},
],
},
description: 'List of automation steps to perform',
displayOptions: {
show: {
resource: ['agenticscraper'],
operation: ['automate'],
},
},
options: [
{
displayName: 'Step Items',
name: 'stepItems',
values: [
{
displayName: 'Step',
name: 'step',
type: 'string',
default: '',
required: true,
description: 'Automation step description (e.g., "Type email@gmail.com in email input box")',
placeholder: 'Type email@gmail.com in email input box',
},
],
},
],
},
];
35 changes: 35 additions & 0 deletions nodes/ScrapegraphAI/ScrapegraphAi.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { smartscraperFields, smartscraperOperations } from '../SmartscraperDescr
import { searchscraperFields, searchscraperOperations } from '../SearchscraperDescription';
import { markdownifyFields, markdownifyOperations } from '../MarkdownifyDescription';
import { smartcrawlerFields, smartcrawlerOperations } from '../SmartcrawlerDescription';
import { agenticscraperFields, agenticscraperOperations } from '../AgenticscraperDescription';

export class ScrapegraphAi implements INodeType {
description: INodeTypeDescription = {
Expand Down Expand Up @@ -54,6 +55,10 @@ export class ScrapegraphAi implements INodeType {
name: 'Markdownify',
value: 'markdownify',
},
{
name: 'Agentic Scraper',
value: 'agenticscraper',
},
],
default: 'smartscraper',
},
Expand All @@ -65,6 +70,8 @@ export class ScrapegraphAi implements INodeType {
...smartcrawlerFields,
...markdownifyOperations,
...markdownifyFields,
...agenticscraperOperations,
...agenticscraperFields,
],
};

Expand Down Expand Up @@ -188,6 +195,34 @@ export class ScrapegraphAi implements INodeType {
returnData.push({ json: response, pairedItem: { item: i } });
}
}

if (resource === 'agenticscraper') {
if (operation === 'automate') {
const url = this.getNodeParameter('url', i) as string;
const useSession = this.getNodeParameter('useSession', i) as boolean;
const stepsData = this.getNodeParameter('steps', i) as { stepItems: Array<{ step: string }> };

// Extract steps from the fixedCollection format
const steps = stepsData.stepItems.map(item => item.step);

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

returnData.push({ json: response, pairedItem: { item: i } });
}
}
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message } });
Expand Down