PHP抓取页面中的邮箱

<?php 
$url='http://www.cnblogs.com/tinyphp/p/3234926.html'; //当页已留邮箱
$content=file_get_contents($url);                         //获取页面内容
function getEmail($str) {                                 //匹配邮箱内容
$pattern = "/([a-z0-9\-_\.]+@[a-z0-9]+\.[a-z0-9\-_\.]+)/"; 
preg_match_all($pattern,$str,$emailArr); 
return $emailArr[0]; 
} 
print_r( getEmail($content)); 
?> 

留下我的邮箱做个测试:tinyphp@163.com

posted @ 2013-08-03 17:41  tinyphp  Views(1455)  Comments(0Edit  收藏  举报