[英]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.