Get RSS feed list

Hi,

I was asked if it was possible to get RSS feeds for use in my KM Obsidian Journal macro without relying on DEVONthink.

I created the following code that does the job and thought I would share it as it may be of use for other needs.

Cheers

Iain

RSS Feeds

--News Headlines
##############################################
# Configuration
##############################################

set RSSfeed to "http://rss.cnn.com/rss/edition.rss" -- rss feed that you want to process
set RSSarticles to 3 -- number of items you want displayed

##############################################
# Code
##############################################
set RSSfeed to do shell script "curl -s " & quoted form of RSSfeed without altering line endings
tell application "System Events"
	set RSSfeed to make new XML data with properties {text:RSSfeed, id:0, name:"untitled"}
	set RSSRecords to {}
	repeat with xmlElement in (XML elements of XML element "channel" of XML element "rss" of RSSfeed whose name is "item")
		set end of RSSRecords to {RSSTitle:value of XML element "title" of xmlElement, RSSLink:value of XML element "link" of xmlElement}
	end repeat
end tell

set theRSS to ""
set limit to RSSarticles
set counter to 0

repeat with a from 1 to the number of RSSRecords
	set counter to counter + 1
	if (counter > limit) then exit repeat
	set theArticle to item a of RSSRecords
	set RSSTitle to RSSTitle of theArticle
	set RSSLink to RSSLink of theArticle
	--set theRSS to theRSS & "<a href=\"" & RSSLink & "\">" & RSSTitle & "</a>" & return -- URL
	set the theRSS to theRSS & "[" & RSSTitle & "](" & RSSLink & ")" & return -- MD
	
end repeat

set the clipboard to theRSS

display dialog theRSS -- for testing purposes remove if not required
2 Likes