The php code of captures the email address in the web page

  • 2020-05-19 04:22:55
  • OfStack

 
<?php 
$url='//www.ofstack.com'; // This page definitely contains an email address.  
$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)); 
?> 

Related articles: