General
cancel
Showing results for 
Search instead for 
Did you mean: 

I need a perl or php script to extract all mail addresses

SOLVED
Go to solution
'chris'
Super Advisor

I need a perl or php script to extract all mail addresses

hi

I need a perl or php script to extract all mail addresses from a homepage, but I have to know which mail address is on which HTML site or on which perl or php site.
I can run this perl script on the webserver machine locally.

kind regards
chris
6 REPLIES
Steven E. Protter
Exalted Contributor
Solution

Re: I need a perl or php script to extract all mail addresses

How about a pre-processor script.

Try this on for size.

wget http://www.mysite.com/index.html

# Replace it with a local file, it doesn't matter.

cat index.html | grep "@" > secondary file.

Nnow you have extracted every line with an @ into a file.

You are now quite close.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Gopi Sekar
Honored Contributor

Re: I need a perl or php script to extract all mail addresses

see whether this is of use to you.

@Files_List contains list of files to be scanned through. you can also use File::Find module to traverse set of directories and get list of files.

#!/usr/bin/perl

foreach $file(@Files_List)
{
open(FH, "$file") || die "Cant open file";

while()
{
chomp($_);
#Following regular expression hopefully matches most of email id. only condition being that before the email id there should be atleast one space. it can match email id's containing alphanumeric, -, _ and .

if ($_ =~ m/\s*([-_.\w]+@[-_.\w]+)\s*.*$/g)
{
print ("->$file<- contains mail id ->$1<-\n");
}
}
}

Regards,
Gopi
Never Never Never Giveup
Gopi Sekar
Honored Contributor

Re: I need a perl or php script to extract all mail addresses


whether the above script is of help to you?
Never Never Never Giveup
'chris'
Super Advisor

Re: I need a perl or php script to extract all mail addresses

thanks for the scripts !

Sorry I didn't check yet, have a lot of work now,
but I'll do next week and I'll report.
renarios
Trusted Contributor

Re: I need a perl or php script to extract all mail addresses

Hi Chris,

here's a schell script which does the same (and some more). It's a piece from a script I use to send people "personal" emails.

The file it reads is called "list" change it to what you want.

Hope it helps.

Cheerio,

Renarios
Nothing is more successfull as failure
'chris'
Super Advisor

Re: I need a perl or php script to extract all mail addresses

thanks !