set TID to AppleScript's text item delimiters
set {startTitles, endTitles} to {{}, {}}
set FolderLocdo to quoted form of (POSIX path of (path to desktop) & "Temp Export Folder" as text)
do shell script "mkdir -p " & FolderLocdo
set xxx to do shell script "curl [url=http://query.yahooapis.com/v1/public/yql?q=select%20title%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.npr.org%2Frss%2Frss.php%3Fid%3D1001%22&diagnostics=true]http://query.yahooapis.com/v1/public/yql?q=select%20title%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.npr.org%2Frss%2Frss.php%3Fid%3D1001%22&diagnostics=true"[/url]
set AppleScript's text item delimiters to {"<item><title>", "</title></item>"}
set xxx to text items 2 thru -2 of xxx
repeat with aTitle in xxx
if aTitle's contents is not "" then set end of endTitles to aTitle's contents
end repeat
set text item delimiters to "." & return
set endTitles to endTitles as text
set AppleScript's text item delimiters to TID
do shell script "echo " & quoted form of endTitles & " > " & FolderLocdo & "/test.txt"
Systems before Snow Leopard do not support multiple text item delimiters.
Try this:
set TID to AppleScript's text item delimiters
set {startTitles, endTitles} to {{}, {}}
set FolderLocdo to quoted form of (POSIX path of (path to desktop) & "Temp Export Folder" as text)
do shell script "mkdir -p " & FolderLocdo
set xxx to do shell script "curl [url=http://query.yahooapis.com/v1/public/yql?q=select%20title%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.npr.org%2Frss%2Frss.php%3Fid%3D1001%22&diagnostics=true]http://query.yahooapis.com/v1/public/yql?q=select%20title%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.npr.org%2Frss%2Frss.php%3Fid%3D1001%22&diagnostics=true"[/url]
set AppleScript's text item delimiters to "<item><title>"
set xxx to text items 2 thru -2 of xxx
set AppleScript's text item delimiters to {""}
set xxx to xxx as text
set AppleScript's text item delimiters to "</title></item>"
set xxx to text items of xxx
repeat with aTitle in xxx
if aTitle's contents is not "" then set end of endTitles to aTitle's contents
end repeat
set text item delimiters to ". " & return
set endTitles to endTitles as text
set AppleScript's text item delimiters to TID
do shell script "echo " & quoted form of endTitles & " > " & FolderLocdo & "/test.txt"
When I test this link on the YQL RSS Console site it doesn’t return any useful results that I can plug into the script
we’ve been working on in this thread.
feed://www.jokesareawesome.com/rss/random/
Just would like to download the random joke that’s posted there for my HA system to read.
Any thoughts on that?
You started the thread asking for titles. If you want the whole feed your YQL statement would start with select * rather than select title. From there, it is just a matter of extracting the text you want by manipulating text item delimiters. Here is a good tutorial: http://macscripter.net/viewtopic.php?id=24656 Try working through it so you can tackle the next one yourself.
set TID to AppleScript's text item delimiters
set FolderLocdo to quoted form of (POSIX path of (path to desktop) & "Temp Export Folder" as text)
do shell script "mkdir -p " & FolderLocdo
set xxx to do shell script "curl [url=http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.jokesareawesome.com%2Frss%2Frandom%2F%22&format=json&callback=cbfunc]http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.jokesareawesome.com%2Frss%2Frandom%2F%22&format=json&callback=cbfunc"[/url]
set AppleScript's text item delimiters to "[CDATA["
set xxx to text items 3 thru -1 of xxx
set AppleScript's text item delimiters to {""}
set xxx to xxx as text
set AppleScript's text item delimiters to "]]>"
set xxx to text item 1 of xxx
set AppleScript's text item delimiters to TID
do shell script "echo " & quoted form of xxx & " > " & FolderLocdo & "/test.txt"
set theString to "ABC"
-- Break apart
set AppleScript's text item delimiters to "B"
set xxx to text items of theString
-- put together
set AppleScript's text item delimiters to {""}
set xxx to xxx as text
That’s a terrific example. It’s easy to perform edits, but for the life of me I’m not getting how to incorporate
them into the existing script. Is there a more basic step by step for this type of editing you may know of?
This one replaces the with a space, which I find I need to do with some other characters as well.
set theString to "D<br />K"
-- Break apart
set AppleScript's text item delimiters to "<br />"
set xxx to text items of theString
-- put together
set AppleScript's text item delimiters to {" "}
set xxx to xxx as text
I have tried modifying the selection portion.
I am trying to write out a text file of only the messages selected, and not the entire mailbox
The following is the latest and a few commented lines to show what I have tried, so far I keep getting class errors.
Anyone see the problem?
--set TID to AppleScript's text item delimiters
set endSubjects to {}
set FolderLocdo to quoted form of (POSIX path of (path to desktop) & "Temp Export Folder" as text)
do shell script "mkdir -p " & FolderLocdo
tell application "Mail"
--tell mailbox "Inbox" of account 1
set theMessages to selected messages of message viewer 1
--set theSubjects to subject of (items of theMessages)
set theSubjects to subject of it's message
--set theSubjects to subject of (text items of theMessages) as rich text
--end tell
end tell
repeat with eachMessage in theMessages
--set theTitles to subject of it's message of theMessages
--end tell
--repeat with myTitle in theTitles
--set AppleScript's text item delimiters to {".", ",", "/", ":", "[", "]"}
set theSubjects to text items of eachMessage
set AppleScript's text item delimiters to {""}
set theSubject to theSubject as text
--if (count of characters of theTitle) > 32 then set theTitle to text 1 thru 32 of theTitle
set end of endSubjects to theSubject
end repeat
set text item delimiters to return
set endSubjects to endSubjectss as text
--set AppleScript's text item delimiters to TID
do shell script "echo " & quoted form of endSubjectss & " > " & FolderLocdo & "/test.txt"
set endTitles to {}
set FolderLocdo to quoted form of (POSIX path of (path to desktop) & "Temp Export Folder" as text)
do shell script "mkdir -p " & FolderLocdo
tell application "Mail"
activate
set theSelectedMessages to selection
set theMessages to theSelectedMessages
repeat with eachMessage in theMessages
tell eachMessage
if sender is "sender@some.com" then
set theSubject to subject
set end of endTitles to theSubject as Unicode text
end if
end tell
end repeat
end tell
set text item delimiters to return
set endTitles to endTitles as Unicode text
do shell script "echo " & quoted form of endTitles & " > " & FolderLocdo & "/test.txt"