I need some help applescripting RSS Feeder
I am creating an applescript that will read the top headlines of US news. Everyone was saying it wasn't possible without using an application but I have two applescripts that work. The first one reads 3 random titles but also reads an address link after. The second reads the title and headline (which is what I was looking for) but continues to read Every link address connected to it. I need some help combing the two to create an applescript the will read the title AND heading of 3-5 random news articles from http://rss.cnn.com/rss/cnn_topstories.rss
Applescript 1:
property RSSURL : "http://rss.cnn.com/rss/cnn_topstories.rss"
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {("<item>" & (ASCII character 13))}
try
do shell script "curl -sS " & quoted form of RSSURL
set rssFeed to every text item of result
set AppleScript's text item delimiters to ASTID
if (count rssFeed) is greater than or equal to 4 then
set rssFeed to items 2 thru 4 of rssFeed
else
set rssFeed to items 2 thru (count rssFeed) of rssFeed
end if
on error errorMsg number errorNum
set AppleScript's text item delimiters to ASTID
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try
say "These are the top news headlines for today."
delay 2
repeat with thisPiece in rssFeed
say (text 8 thru -9 of (first paragraph of thisPiece))
delay 1
say (text 14 thru -15 of (third paragraph of thisPiece))
delay 2
end repeat
say "End of headlines."
end
--Reads 3 random headlines and one address after each
Applescript 2:
property RSSURL : "http://rss.cnn.com/rss/cnn_topstories.rss"
property RSSFile : POSIX path of ((path to temporary items as Unicode text) & "rss.xml")
tell application "System Events"
activate
try
do shell script "curl -sS " & quoted form of RSSURL & " > " & quoted form of RSSFile
set rssFeed to XML file RSSFile
set rssItems to XML elements 1 thru 3 of XML element "channel" of XML element "rss" of contents of rssFeed whose name is "item"
get value of XML element "title" of XML element "channel" of XML element "rss" of contents of rssFeed
say "These are today's top news headlines from " & result
delay 2
on error errorMsg number errorNum
display alert "Error " & errorNum message errorMsg buttons "Cancel" default button 1
return false
end try
repeat with thisItem in rssItems
try
say (get value of XML element "title" of thisItem)
on error
say "No title for this item."
end try
delay 1
try
say (get value of XML element "description" of thisItem)
on error
say "No description for this item."
end try
delay 2
end repeat
say "End of headlines."
end tell
--Reads headline and detail and Every link address after