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:

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 | 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 | query xml //item/link 

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

โ”‚ # โ”‚           //item/link            โ”‚
โ”‚ 0 โ”‚ โ”‚
โ”‚ 1 โ”‚ โ”‚
โ”‚ 2 โ”‚ โ”‚
โ”‚ 3 โ”‚ โ”‚
โ”‚ 4 โ”‚ โ”‚
โ”‚ 5 โ”‚ โ”‚
โ”‚ 6 โ”‚ โ”‚
โ”‚ 7 โ”‚ โ”‚
โ”‚ 8 โ”‚ โ”‚
โ”‚ 9 โ”‚ โ”‚

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

http get | from xml | get content | get content | get 0 | where tag == item | get content | flatten | where tag == link | get content | flatten | get content