Create Markdown list from RSS feed
I was asked if it was possible to get RSS feeds for use in Keyboard Maestro Obsidian Journal macro without relying on DEVONthink.
I created the following code that does the job entirely in Applescript. The list created is in Markdown format but there is also an option to create a HTML version.
I created the following code that does the job entirely in Applescript. The list created is in Markdown format but there is also an option to create a HTML version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################# | |
# Title: Get RSS feeds links and convert to Markdown | |
############################################## | |
# Iain Dunn | |
# Logic2Design | |
# www.logic2design.com | |
# logic2design@icloud.com | |
# Last update: 16 January 2022 | |
# Version: 2 | |
############################################## | |
# 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 |
Comments
Post a Comment