I use Google News often because (believe it or not) I’m still on a dial-up modem connection and Google News provides a quick overview of the day’s headlines.
But when I’m trying to follow a breaking news story, it generally takes several clicks and a deal of waiting to drill down to the latest reports.
So, I put the following together to make short(er) work of searching. The script will search either Google News or Associated Press news (via Google) for stories sorted by date.
It also preserves the last set of search terms in a text file (in Application Support) so if the script is used from a keyboard command utility app, the text file saves the search terms… as a property might be saved.
I launch it from a bookmark in Safari, but that’s a another story…
This is compiled and works on 10.4.11. I wonder if it still works for those on Leopard or Snow Leopard.
If not, and if anyone has the patience to tweak it, I’d like to see the working result and retest it here on Tiger.
If it seems useful to others, I’ll post it to Code Exchange.
Thanks…
Peter B.
set app_support to (path to application support from user domain)
tell application "Finder"
try
make new folder in folder app_support with properties {name:"Search Logs"}
end try
end tell
set search_log to (path to application support from user domain) & "Search Logs:News Search.txt" as text
try
set search_terms to read file search_log
on error
set search_terms to ""
end try
tell me to activate
display dialog "Enter Search Terms..." & return & return default answer search_terms buttons {"Cancel", "Search AP", "Search All News"} default button 3 with title "News Search"
copy the result as list to {search_terms, button_returned}
if button_returned is "Search AP" then
set search_prefix to "http://news.google.com/news/search?pz=1&cf=all&ned=us&hl=en&as_q="
set search_suffix to "&as_epq=&as_oq=&as_eq=&as_scoring=n&btnG=Search&as_drrb=q&as_qdr=a&as_minm=4&as_mind=21&as_maxm=5&as_maxd=21&as_nsrc=associated+press&as_nloc=&geo=&as_author=&as_occt=any"
end if
if button_returned is "Search All News" then
set search_prefix to "http://news.google.com/news/search?pz=1&cf=all&ned=us&hl=en&q="
set search_suffix to "&cf=all&scoring=n"
end if
try
open for access file search_log with write permission
set eof of file search_log to 0
write search_terms to file search_log as string starting at eof
close access file search_log
on error
close access file search_log
end try
set ASTID_Priors to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set amended_search_terms to every text item of search_terms as list
set AppleScript's text item delimiters to {"+"}
set amended_search_terms to every text item of amended_search_terms as text
set AppleScript's text item delimiters to ASTID_Priors
set search_link to search_prefix & amended_search_terms & search_suffix
open location search_link
(*
tell application "Safari"
activate
try
set _exists to document 1
tell front document
set URL to search_link
end tell
on error
make new document
tell front document
set URL to search_link
end tell
end try
end tell
*)