Finding email addresses on a webpage

I am new to Automator and I want to feed it a website and have it spit out all email addresses on that site.

So far, I have:

Get Specified URLS (I manually input the URLs to be searched)
Get Text from WebPage (This spits out the text from that URL)

And now I am lost. There must be a "search text" automation or something that can search out and copy the email addresses right?

Mac OS X (10.6.5)

Posted on Nov 20, 2010 5:21 PM

Reply
1 reply

Nov 20, 2010 6:59 PM in response to moreofhim

You can use a *Run AppleScript* action to do the text processing. I haven't performed extensive testing with the AppleScript handler (it works with what I can find), but the following workflow should be close:

1) *Get Specified URLs* ( add your web pages here )
2) *Get Text from Webpage*
3) *Filter Paragraphs* { Return paragraphs that are not empty }
4) *Run AppleScript*
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters}

set output to {}
repeat with anItem in input
set output to output & (getEmailAddresses from anItem)
end repeat

return output
end run


to getEmailAddresses from someText
(*
extract email addresses "somename@somehost" or "<somename@somehost>" from SomeText
the "<>" characters, if any, are trimmed from the result
parameters - someText [text]: the text to extract the address from
returns [list]: the email addresses
*)
set someText to someText as text
set {atCharacter, delimiter} to {"@", space}
set emailList to {}
repeat until someText is ""
set pivotOffset to (offset of atCharacter in someText)
if pivotOffset is 0 then exit repeat
set here to (offset of delimiter in (text pivotOffset thru -1 of someText))
if result is 0 then
set there to reverse of text items of (text 1 thru -1 of someText) as text
set someText to ""
else
set there to reverse of text items of (text 1 thru (pivotOffset + result - 2) of someText) as text
set someText to text (here + pivotOffset) thru -1 of someText
end if
set anEmail to reverse of text items of (text 1 thru ((offset of delimiter in there) - 1) of there) as text
if anEmail begins with "<" then set anEmail to text 2 thru -1 of anEmail
if anEmail ends with ">" then set anEmail to text 1 thru -2 of anEmail
set the end of emailList to anEmail
end repeat
return emailList
end getEmailAddresses
</pre>

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Finding email addresses on a webpage

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.