Return domain name level only

Hi all.

How to? …

I would like to launch a search with DevonAgent and return ONLY the top level domain name result ( only, not…).

Then, in a perfect world, I would also get a de-dupe so that only uniques are returned.

The goal is to search for whatever and as long as it appears on a website, only the homepage is returned.



This is not possible, the only workaround is to post-process the results via AppleScript. E.g. the following script displays all top level domains in a browser window:

-- View top level domains of results
-- Created by Christian Grunenberg on Tue 15 2013.
-- Copyright (c) 2013. All rights reserved.
	tell application "DEVONagent"
		if not (exists search window 1) then error "No search window is open."
		set theSearch to search window 1
		if searching of theSearch then error "Search is not yet complete."
		set theResults to search results of theSearch
		if (count of theResults) is 0 then error "No search results."
		set pathToAdditions to ((path to application id "com.devon-technologies.agent" as string) & "Contents:Resources:Script Additions.scpt") as alias
		set helperLibrary to load script pathToAdditions
		set this_HTML to "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><title>" & helperLibrary's convertText2XML(name of theSearch as string) & "</title></head><body><small>"
		set theDomains to {}
		repeat with theResult in theResults
			set theURL to (URL of theResult) as string
			set od to text item delimiters of AppleScript
			set text item delimiters of AppleScript to "/"
			set theDomain to (text items 1 thru 3 of theURL) as string
			set text item delimiters of AppleScript to od
			if theDomains does not contain theDomain then
				set theDomains to theDomains & theDomain
				set this_title to my helperLibrary's convertText2XML((title of theResult) as string)
				set this_abstract to my helperLibrary's convertText2XML((summary of theResult) as string)
				set this_URL to my helperLibrary's convertText2XML(theURL)
				set this_HTML to this_HTML & "<p><div><h3>" & this_title & "</h3></div>" & "<div>" & this_abstract & "</div><div><a href=\"" & this_URL & "\">" & this_URL & "</a></div></p>"
			end if
		end repeat
		set this_HTML to this_HTML & "</small></body></html>"
		helperLibrary's loadHTML(this_HTML)
	end tell
on error error_message number error_number
	if error_number is not -128 then display alert "DEVONagent" message error_message as warning
end try

THANKS. This helps a lot! Just tried it and for now I can work with this.
If you do decide to implement this in a roadmap I would give you a couple of suggestions but, again, for now this really helps.