Skip to main content
  1. Blog/

Get items from rss feed with Nushell ๐Ÿ˜

·288 words·2 mins

I wanted to get some links to some content on the Citizen’s journalism site Folkets to be able to work with this with AI.

I could have used the site map.

But the site has several RSS feeds that contain mere useful information and are structured more in line with the user facing structure of the site.

I just needed to get the front page feed which is available here:

https://www.folkets.dk/rss.xml

Nushell is great for working with structured data and has most of what I needed builtin. Except I needed to use the query plugin also.

I used these:

Now to get the actual links from the feed all I had to do was give this command at my terminal:

 http get https://www.folkets.dk/rss.xml | query web -q item | each { $in.3 | str trim }

There is an easier way to get the links (but usually not in the same order as the source):

 http get https://www.folkets.dk/rss.xml | query xml //item/link 

Then Nushell gives me a simple table with the links like so:

โ•ญโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ # โ”‚           //item/link            โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 0 โ”‚ https://www.folkets.dk/node/5036 โ”‚
โ”‚ 1 โ”‚ https://www.folkets.dk/node/5041 โ”‚
โ”‚ 2 โ”‚ https://www.folkets.dk/node/5038 โ”‚
โ”‚ 3 โ”‚ https://www.folkets.dk/node/5035 โ”‚
โ”‚ 4 โ”‚ https://www.folkets.dk/node/5040 โ”‚
โ”‚ 5 โ”‚ https://www.folkets.dk/node/5042 โ”‚
โ”‚ 6 โ”‚ https://www.folkets.dk/node/5037 โ”‚
โ”‚ 7 โ”‚ https://www.folkets.dk/node/5043 โ”‚
โ”‚ 8 โ”‚ https://www.folkets.dk/node/5039 โ”‚
โ”‚ 9 โ”‚ https://www.folkets.dk/node/5032 โ”‚
โ•ฐโ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

This can even be done with Nushell without any plugins like so:

http get https://www.folkets.dk/rss.xml | from xml | get content | get content | get 0 | where tag == item | get content | flatten | where tag == link | get content | flatten | get content