Good day, ladies and gentlemans. I'm a newbie in programming and my problem is in creating a php parser for开发者_运维知识库 e-mail addresses. I need to parse a whole web-site and create a .txt file with e-mails. So, that is the question. What must I use? Should it be a proper php function *file_get_contents* with any arguments or maybe a PHPparser_Generator from PEAR project? Any ideas? P.S.: I would like to remind you not to write the code itself, 'cause I want to do it myself. Just any hint.
Thanks a lot. Best regards, Aen
Off the top of my head, something like.....
preg_match_all("/([a-z0-9\._%+!$&*=^|~#%\'`?{}/\-]+@[a-z0-9\.-]+\.[a-z]{2,6})/i",
file_get_contents($somefile), $matches, PREG_PATTERN_ORDER);
foreach ($matches[0] as $addrspec) {
mail($addrspec, "hello", $msg);
}
Yes, file_get_contents
will do it. Assign that to a variable then use preg_match_all to find this expression: /[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i
. This is a regular expression which matches email addresses.
精彩评论