Storing and loading content from filesystem

Hello, i want to scrape a knowledge base and send myself new posts. For this I plan to store the article IDs somwhere in n8n and then filter them out in subsecuent executions.

Can this be done?

Welcome to the community @luisito345!

There are multiple ways to store data. If it is just very little data like a few values you can store it directly in the workflow with static data:
https://docs.n8n.io/#/nodes?id=method-getworkflowstaticdatatype

Apart from that can you anytime save data in a file:
https://n8n.io/integrations/n8n-nodes-base.readBinaryFile
https://n8n.io/integrations/n8n-nodes-base.writeBinaryFile

Or in a database like Redis, Mongo, Postgres or MySQL:
https://n8n.io/integrations/n8n-nodes-base.redis
https://n8n.io/integrations/n8n-nodes-base.mongoDb
https://n8n.io/integrations/n8n-nodes-base.postgres
https://n8n.io/integrations/n8n-nodes-base.mySql

1 Like

You might want to have a look here. It’s a workflow that tracks sitemap changes.

How to get new RSS item?

Until there is no better support for tracking node data changes it’s going to be ugly - but doable.

1 Like

Thanks all for the information, I’m having a hard time making this work, can some one point where the problems are??

In a previous function I generate a lot of items, they haven an ID, so my idea is to get the previous latest id and send all items with a bigger number, then saving the new id in node data. Or that is what i want to believe it does.

Function Code
let SITEURL = 'https://site.com';
let HTMLHEADER = '<html>'; //'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
//<html xmlns="https://www.w3.org/1999/xhtml">
//<body>';
let HTMLFOOTER = '</body></html>';
let emailText = `${HTMLHEADER}` + 'KB de Site: \n\n<ul>';

let idMasGrande = 0;
let newidMasGrande = 0;
const staticNodeData = getWorkflowStaticData('node');
const oldidMasGrande = staticNodeData.idMasGrande;
const newItems = [];

for (let item of items) {
  if (item.json.articuloID >= idMasGrande) {
      newidMasGrande = item.json.articuloID;
      item.json.estado = "pasaFiltro";
      newItems.push({ json: item });
  }
  // filtrarlo
  if (item.json.articuloID > oldidMasGrande) {
      //newidMasGrande = item.json.articuloID;
      //item.json.estado = "pasaFiltro";
      //newItems.push({ json: item });
  }
  // fin filtrarlo

}
staticNodeData.idMasGrande = newidMasGrande;
// fim seteo el id

emailText += `\n\n results:`;
for (let item of newItems) {
  emailText += `<li>${item.json.estado} * ${item.json.articuloTitulo}
   ${item.json.airticuloDate} - ${SITEURL}${item.json.articuloHref}\n
   ${item.json.articuloCuerpo}\n</li>`;
}
emailText += `<ul> ${HTMLFOOTER}`;

return [{json: {emailText}}]

Also, i love to use ‘console.log’ is there any way for me to just log/debug messages ?

thanks

Hey @luisito345, where are you having the issue exactly?

Yes, you can use console.log() in the function node, just add it and you will see the data in the terminal you ran n8n.

1 Like