Can't download e-mail addresses from pages automatically

Maybe I am missing something basic, but I could not find how to get DA to do this for me (and DA can do everything it seems!).

I am an archaeologist and I publish an annual directory of Archaeology Field Schools. What I have done in the past is use DA to find pages with both archaeology field school on them, then I contact the appropriate institution to let them know that they can advertise their field school on my archaeology web site/mailing list.

A problem is that there is a lot of drudgery in going to each page, selecting the e-mail address and cutting and pasting it into my editor. What I want to do is have DA pull the e-mail addresses from my search results and put them into a file for me. Is this function built in to DA and I am missing it? I really do not want to manually sift through my 456 results :slight_smile:

My search query I am using is:

(Archaeology Field School) OR (Archaeological Field School) AND [2009 OR 2008 OR 2007 OR 2006]

Thanks for any advice!

You probably want to create a search set for this query (Tools > Edit Search Sets…) where you use the Email addresses scanner (in the General tab). In the Action tab you can email the results to yourself. Have you tried that?

If you’ve used the Email scanner, then you could run this script in Apple’s Script Editor:


tell application "DEVONagent"
	activate
	try
		if not (exists search window 1) then error "No search windows are open."
		
		set theSearch to search window 1
		if theSearch is searching then error "Search not yet complete."
		
		set theResults to search results of theSearch
		repeat with theResult in theResults
			set theURL to URL of theResult
			set theObjects to scanner objects of theResult
			set theLinks to ""
			repeat with theObject in theObjects
				set theLinks to theLinks & theObject & return
			end repeat
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONagent" message error_message as warning
	end try
end tell

Christian - Thank you! That is (almost) exactly what I am looking for! The only problem is that it is only returning on e-mail address when I search on a result that has e-mails on each web page that showed up in the results. I looked at the code but I could not figure out what was causing it to only return one result. I have not used Apple script much and my general scripting skills are rusty.

Do you have any ideas?

Thanks again!

The emails might be hidden in some way not supported by the scanner. Do you have an example URL that should be accepted but isn’t?

Sure - Here is the first result of my DA results

und.edu/dept/undar/fieldscho … tml#jmp0

The e-mail is in the last paragraph under:

Application and Contact Information:

The next result is

archaeological.org/webinfo.p … 039#jmp0

It is in the sentence under “Get Lecture Information” button.

I ran DA using this search term:

(Archaeology Field School) OR (Archaeological Field School) AND [2009 OR 2007 OR 2008 OR 2006]

To run the Apple Script I copied your code into the Apple Script editor and clicked on “run”

Not sure if this helps, but I was looking at the script again and this time when I ran it I watched the Event Log window. And as the script ran it looked like it was parsing the files fine for the e-mail. I could see the e-mail addresses from each page scrolling up the event log, but the only one that was displayed in the results window was the very last e-mail shown in the Events Log window.

Minor bug of the script, here’s a fixed version:


tell application "DEVONagent"
	activate
	try
		if not (exists search window 1) then error "No search windows are open."
		
		set theSearch to search window 1
		if theSearch is searching then error "Search not yet complete."
		
		set theResults to search results of theSearch
		set theLinks to ""
		repeat with theResult in theResults
			set theURL to URL of theResult
			set theObjects to scanner objects of theResult
			repeat with theObject in theObjects
				set theLinks to theLinks & theObject & return
			end repeat
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONagent" message error_message as warning
	end try
end tell

BTW:
Don’t use [] in your search term, anything inside will be ignored. Use () instead.

Thank you!

When I first ran the corrected script I was getting no results at all. So I checked the Events Log and I saw that instead of parsing the e-mail addresses, it was parsing the URL’s. I went through the script again and saw that there is the line:

And I checked my new DA search and saw on todays search I saw I forgot to choose “email address” under my scanner options in DA.

And thanks for the reminder to use the () and not the []!

Thanks a million!