applescript rss feed help

I have this script and I want it to read three headlines from the google science and tech rss feed from news.google.com

it reads the titles of the article fine but the description is all messed up with html code all over it and I'm wondering if any of you might be up looking it over and helping me out. Thanks!


property RSSURL : "http://news.google.com/news?ned=us&topic=t&output=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 fileRSSFile


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

display dialog "These are today's top news headlines from " & result


delay 2

on error errorMsgnumbererrorNum


display alert "Error " & errorNummessageerrorMsgbuttons "Cancel" default button 1

return false

end try


repeat with thisItem in rssItems

try

display dialog (get value of XML element "title" of thisItem)

on error

display dialog "No title for this item."

end try


delay 1


try

display dialog (get value of XML element "description" of thisItem)

on error

display dialog "No description for this item."

end try


delay 2

end repeat

display dialog "End of headlines."

end tell

Mac OS X (10.7.1)

Posted on May 8, 2012 10:30 PM

Reply
1 reply

May 9, 2012 1:36 PM in response to derekshull

Try this :


replace this line in your script

display dialog(getvalueofXML element"description"ofthisItem)


by these lines

do shell script "echo " & (quoted form of (get value of XML element "description" of thisItem)) & " | /usr/bin/perl -ne 'use HTML::Entities;s/\\.\\.\\..*/.../;print decode_entities($_);' | /usr/bin/textutil -format html -convert txt -stdin -stdout | /usr/bin/sed '1,4d;/f6f6f\">.*/d' "

display dialogtheresult

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

applescript rss feed help

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.