in applescript

Find URL feed via Safari and NetNewsWire

Guy Kawasaki asked for quick ways to find the RSS feed of a web site. NetNewsWire does a fine job subscribing to sites so I thought it might be up to the task. It is.

Run this to pull the current website from Safari, subscribe in NetNewsWire, and return the RSS feed URL, optionally copying it to the clipboard.

[code lang="AppleScript"]
tell application "Safari"
    set thisPage to do JavaScript "document.URL" in document 1
end tell
tell application "NetNewsWire"
    set subcount to (count of subscriptions)
    set theresult to subscribe to thisPage
    delay 2  --gives NNW time to retrieve the RSS feed
    set thefeed to RSS URL of subscription (subcount + 1)
    if thefeed is equal to thisPage then
        display dialog "No feed found"
    end if
    display dialog thefeed buttons {"Clipboard", "OK"} default button 1
    if the button returned of the result is "Clipboard" then
        set the clipboard to thefeed
    end if
end tell

Click here to open the script and give it a whirl.

Update: Renamed “NetNewsWire 3” to “NetNewsWire” since that’s what the app is called when you download it.

Also, NetNewsWire takes a split second to work its magic. If the script isn’t working for a site, try increasing the “delay 2” line to “delay 5” or something.

For those with something to say: