Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save logic2design/25e05fd5297419343a07682068c4a227 to your computer and use it in GitHub Desktop.
Save logic2design/25e05fd5297419343a07682068c4a227 to your computer and use it in GitHub Desktop.
Create a markdown or HTML list from a RSS feed.
#############################################
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment