search
Homephp教程php手册php结合正则批量抓取网页中邮箱地址,抓取邮箱地址

php结合正则批量抓取网页中邮箱地址,抓取邮箱地址

php如何抓取网页中邮箱地址,下面我就给大家分享一个用php抓取网页中电子邮箱的实例。

<&#63;php
  $url='http://www.bkjia.com'; //要采集的网址 
  $content=file_get_contents($url);
  //echo $content;
  function getEmail($str) {
  //$pattern = "/([a-z0-9]*[-_\.]&#63;[a-z0-9]+)*@([a-z0-9]*[-_]&#63;[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})&#63;/i";
  $pattern = "/([a-z0-9\-_\.]+@[a-z0-9]+\.[a-z0-9\-_\.]+)/";
  preg_match_all($pattern,$str,$emailArr);
 
  return $emailArr[0];
  }
  print_r( getEmail($content));
  &#63;>

方法2:

<&#63;php 
$url='http://www.bkjia.com'; //当页已留邮箱
$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)); 
&#63;>

以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)