[英]how to extract email from website site recursively through linux command
我想递归地提取电子邮件表单站点,这样如果一个站点有其他电子邮件链接,它也会遍历这些页面并提取电子邮件 ID:s。
我对深度级别 2 执行了以下操作:
wget -r -l 2 -O - some site name |grep -E -o "[a-z0-9.]+@[a-z0-9.-]+.[a-z]{2,4}">>some.txt
但是当我执行这个命令时,它只会创建一个文件“ some.txt
”并且不会提取任何 email-id:s。
为什么不执行递归 wget 并将站点存储在本地,然后在本地文件系统上的站点上执行递归 grep (grep -r)? 只需在脚本末尾添加 rm -Rf 即可在完成后删除站点。
根据使用 PHP:第 1 点)。 开发人员以 HTML 实体格式 (rish) HTML 实体添加电子邮件 ID:
第 2 点)。 电子邮件写在 href="mailto:your@example.com" 上。 所以我们可以把它作为正则表达式。
<?php
$str = '<div class="call-to-action ">
<a title="Email" class="contact contact-main contact-email "
href="mailto:info@canberraeyelaser.com.au?subject=Enquiry%2C%20sent%20from%20yellowpages.com.au&
body=%0A%0A%0A%0A%0A------------------------------------------%0AEnquiry%20via%20yellowpages.com.au%0Ahttp%3A%2F%2Fyellowpages.com.au%2Fact%2Fphillip%2Fcanberra-eye-laser-15333167-listing.html%3Fcontext%3DbusinessTypeSearch"
rel="nofollow" data-email="info@canberraeyelaser.com.au">
<span class="glyph icon-email border border-dark-blue with-text"></span><span class="contact-text">Email</span>
<a href="mailto:rishabhdubey20@gmail.com">
</a>
</div>';
// $str = file_get_contents(http://example.com) ; (to get emails from URL in place of file_get_contents i use to prefer CURL) .
$str = html_entity_decode($str);
$regex = "/mailto:([^?]*)/";
if ($rex = preg_match_all($regex, $str,$matches_out)) {
echo "Found a match!";
echo "<pre>";
var_dump($matches_out[0]);
} else {
echo "The regex pattern does not match. :(";
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.