您的位置:首页 > 编程语言 > PHP开发

一个用php抓取网页中电子邮箱的实例

2015-02-26 10:34 309 查看
原文出自: http://outofmemory.cn/code-snippet/36020/php-how-zhuaqu-wangye-youxiangdizhi-code
php如何抓取网页中邮箱地址,下面我就给大家分享一个用php抓取网页中电子邮箱的实例。 原文来自: www.pc100.net

<?php
/**
desc:采集网页中的邮箱的代码
link:www.pc100.net
date:2013/2/24
*/
$url='http://www.pc100.net'; //要采集的网址
$content=file_get_contents($url);
//echo $content;
function getEmail($str) {
//$pattern = "/([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?/i";
$pattern = "/([a-z0-9\-_\.]+@[a-z0-9]+\.[a-z0-9\-_\.]+)/";
preg_match_all($pattern,$str,$emailArr);

return $emailArr[0];
}
print_r( getEmail($content));
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: