JSON Parsing URL Attribute

Hey team,

I have only really started picking up N8N in an effort to simplify some of my IFTTT and other aggregate services, so please excuse me if I may have missed something, and do feel free to point me at a workflow or tutorial so I can work through what I am doing.

Initial PoC I am keen to get working:

Get JSON data via HTTP request > Parse output and another HTTP Request to loc attribute (URL) > Parse data to extract headings > Webhook to Discord

In essence, I have a JSON feed of news websites I want to keep across, and I’d like N8N to be able to perform a HTTP request to each. I have no issues receiving my JSON object into N8N, I think I just need a function to only grab the loc attribute from all items - though, I don’t know if I need to build a new object/array of just those URLs, or can I pass them straight into a HTML Request somehow. I don’t plan on using the other JSON data in this first instance.

I’ve provided a dummy below to show current structure.

{
  "sites": [
    {
      "loc": "https://www.newsite1.com/",
      "lastmod": "2020-12-19",
      "changefreq": "daily",
      "priority": "0.7"
    },
    {
      "loc": "https://www.newsite2.com/",
      "lastmod": "2020-12-20",
      "changefreq": "daily",
      "priority": "0.8"
    },
    {
      "loc": "https://www.newsite3.com/",
      "lastmod": "2020-12-18",
      "changefreq": "daily",
      "priority": "0.4"
    }
  ]
}

Am I approaching this the right way with N8N? or is there another way I should be handling the JSON objects rather than within a function (ie. maybe the HTML Extract is good at this natively?)

Welcome to the community @burnman!

What you have to do is to split each of the sites in an own item. As soon as you have that you can referene the “loc” property directly in the HTTP Request node and it will do a request for each page.

Here a link to the documentation which describes how that is possible:

And here an example workflow which implements it with the example-data you did provide:

1 Like