How to find email address from a website url

Authors: CodeToday | PHP Code | Views: 701 | Posted: 05 AM: 09/05/2017

How to find email address from a website urlIn this article I will guide you to get email address directly from the website url, this is important if you want to have a quality email list. You can also use the foreach loop to get multiple website urls at once

See AlsoHow to Find email address from bulk domain names
                 How to get Social Networks from a Website





The basic knowledge you must have in this article is

1. Curl_init ()function
2. Regular expression preg_match_all
3. Foreachfunction

curl_init () function  (function.php)

<?
function fread_url($url,$ref="")
    {
        if(function_exists("curl_init")){
            $ch = curl_init();
            $user_agent = $_SERVER['HTTP_USER_AGENT'];
            curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
            curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
            curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
            curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
            curl_setopt( $ch, CURLOPT_URL, $url );
            curl_setopt( $ch, CURLOPT_REFERER, $ref );
            curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
 	    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);     
	    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            $html = curl_exec($ch);
            curl_close($ch);
        }
        else{
            $hfile = fopen($url,"r");
            if($hfile){
                while(!feof($hfile)){
                    $html.=fgets($hfile,1024);
                }
            }
        }
	    $html = str_replace('<b>','',$html);
	    $html = str_replace('</b>','',$html);
	    $html = str_replace('<br>','',$html);
	    $html = str_replace('<strong>','',$html);
	    $html = str_replace('</strong>','',$html);		
        return $html;
}
?>

index.php

If you want to format the form under bootstrap you can add a bootstrap library, otherwise you can use your format.

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<?
include "function.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How to find email address from a website url</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1>How to find email address from a website url</h1>
<form action="" method="post" class="form-horizontal">
<div class="form-group">
<input type="text" name="domain" id="domain" value="<?=$_POST['domain']?>" class="form-control" placeholder = "Enter website url here ..." required/>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-info">Extract Now</button>
</div>
</form>
<?
if(isset($_POST['submit'])){

$url  = $_POST['domain'];
$text = fread_url($url);				
$resEmail  = preg_match_all("/[a-z0-9_-+][email protected][a-z0-9-]+.([a-z]{2,3})(?:.[a-z]{2})?/i",strtolower($text),$matches);
if ($resEmail) { 		   
	foreach($matches[0] as $email) { 
		$emailList[] = $email;
	}				
}	
$emailLists = @array_unique($emailList);
print_r($emailLists);
}
?>
</div>
</body>
</html> 

If you have any questions, please leave a message below