Home  >  Article  >  Backend Development  >  How to use php to grab the email address code in the web page

How to use php to grab the email address code in the web page

WBOY
WBOYOriginal
2016-07-25 08:42:47992browse
  1. /**
  2. desc: code to collect the email in the webpage
  3. */
  4. $url='http://www.xxx.net'; //The URL to be collected
  5. $content=file_get_contents($url);
  6. //echo $content;
  7. function getEmail($str) {
  8. //$pattern = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([ a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i";
  9. $pattern = "/([a-z0-9-_.]+@[a-z0-9]+.[a-z0-9-_.]+)/";
  10. preg_match_all($pattern,$str ,$emailArr);
  11. return $emailArr[0];
  12. }
  13. print_r( getEmail($content));
  14. ?>
Copy code

How to use, email address, php


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