<?php
ini_set('memory_limit', '128M');
$file = "gprofiles-emails.txt";
$fh = fopen($file, 'a') or die("can't open file");
function extract_emails_from($text){
preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $text, $matches);
return $matches[0];
}
$lines = file("gprofile-001.txt");
foreach($lines as $line)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $line);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.23 (Windows NT 5.1; U; en)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
$a = curl_exec($ch);
$emails = extract_emails_from($a);
if(empty($emails)) {
echo "empty\r\n";
}else{
echo "found\r\n";
$mails = $emails."\r\n";
fwrite($fh, $mails);
}
}
?>