Eğer Web Sitesinden mail adresini almak isterseniz örnek kod:
<?php function get_web_page($url) { $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_USERAGENT => "Mozilla/5.0 (compatible; email-bot/1.0)", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_TIMEOUT => 30, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false ); $ch = curl_init($url); curl_setopt_array($ch, $options); try { $content = curl_exec($ch); } catch (Exception $e) { curl_close($ch); return false; } $header = curl_getinfo($ch); curl_close($ch); $header["content"] = $content; return $header; } // E-posta adresini bulmak için regex ve cfemail desteği function getMailAdressRegex($string) { preg_match('/([a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,})/', $string, $mailAdress); if (count($mailAdress) > 0) { return $mailAdress[0]; } else { $cfCheck = checkCfMail($string); if ($cfCheck != false) { return cfDecodeEmail($cfCheck); } return false; } } function checkCfMail($input) { preg_match('/data-cfemail="(.*?)"/', $input, $mailAdressArray); return $mailAdressArray[1] ?? false; } function cfDecodeEmail($encodedString) { $k = hexdec(substr($encodedString, 0, 2)); $email = ''; for ($i = 2; $i < strlen($encodedString) - 1; $i += 2) { $email .= chr(hexdec(substr($encodedString, $i, 2)) ^ $k); } return $email; } // Href’i normalize et (mutlak/bağıl link vs) function normalizeLink($url, $site) { if (strpos($url, 'http') === 0) { return $url; } else if (strpos($url, '/') === 0) { // domain.com/iletisim gibi $parsed = parse_url($site); $domain = $parsed['scheme'] . '://' . $parsed['host']; return $domain . $url; } else { // domain.com/iletisim gibi return rtrim($site, '/') . '/' . ltrim($url, '/'); } } // İletişim/contact linkini bulup mail arar function getContactLink($HTML, $site) { $contactPattern = '/iletisim|contact|bize-ulas|bizeulas|bize-yaz|bizeyaz/i'; $dom = new DOMDocument(); if (empty($HTML)) return false; @$dom->loadHTML($HTML); $crdx = new DOMXPath($dom); $linkler = $crdx->evaluate("//a"); foreach ($linkler as $href) { $url = $href->getAttribute('href'); if (preg_match($contactPattern, $url)) { $link = normalizeLink($url, $site); $contactdata = get_web_page($link); if ($contactdata && isset($contactdata["content"])) { $mailAdress = getMailAdressRegex($contactdata["content"]); if ($mailAdress) return $mailAdress; } } } return false; } // Ana sayfada e-posta bulamazsa iletişimde ara function getMailAdressFromWebSite($website) { $data = get_web_page($website); if (!$data || !isset($data["content"])) return false; // HTTP meta refresh ile yönlendirme kontrolü preg_match('|content="\d+;url=(.*?)"|i', $data["content"], $refreshLink); if (count($refreshLink) > 0) { $data = get_web_page($refreshLink[1]); $website = $refreshLink[1]; } $mail = getMailAdressRegex($data["content"]); if (!$mail) { $mailContact = getContactLink($data["content"], $website); return $mailContact ?: false; } return $mail; } // TEST $mail = getMailAdressFromWebSite("https://www.tasarimrehberi.com/"); $returnArray["mail_adress"] = $mail ?: ""; echo json_encode($returnArray, JSON_UNESCAPED_UNICODE); ?>