Php uses regular expressions to batch capture email addresses on webpages and capture email addresses
How does php capture email addresses on webpages? I will share with you an example of using php to capture email addresses on webpages.
<? Php $ url = 'HTTP: // www.bkjia.com '; // url to be collected $ 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);?>
Method 2:
<? Php $ url = 'HTTP: // www.bkjia.com '; // when the page has been reserved email $ content = file_get_contents ($ url); // obtain the Page content function getEmail ($ str) {// match the email content $ pattern = "/([a-z0-9 \-_ \.] + @ [a-z0-9] + \. [a-z0-9 \-_ \.] +)/"; preg_match_all ($ pattern, $ str, $ emailArr); return $ emailArr [0];} print_r (getEmail ($ content);?>
The above is all the content of this article. I hope you will like it.