Excel VBA - 网站使用脚本MSXML隐藏元素

问题描述

我正在尝试从该网站 https://www.construction.co.uk/c/689533/3d-structural-detailing-services-limited抓取电子邮件 ID,但该网站以某种方式隐藏电子邮件以防止抓取机器人。

需要帮助更新 VBA 代码以从网站获取电子邮件,或者如果您有其他选择,请告诉我。

网站的 HTML 是

<div class="compInfoDetail">
<script>document.write(emrp('ufsftb/cfotpo.tifuumfA4etet/dp/vl','construction.co.uk'));</script>
<a href="mailto:teresa.benson-shettle@3dsds.co.uk?subject=Contact from construction.co.uk">
teresa.benson-shettle@3dsds.co.uk
</a></div>

VBA 代码

Sub construction_uk_contact_xml()
Dim IE As MSXML2.XMLHTTP60
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLBody As MSHTML.HTMLBody
url = Selection.Value
Set IE = New MSXML2.XMLHTTP60
IE.Open "GET",url,False
IE.Send
While IE.ReadyState <> 4
    DoEvents
Wend
Set HTMLDoc = New MSHTML.HTMLDocument
Set HTMLBody = HTMLDoc.body
HTMLBody.innerHTML = IE.responseText
Set infos = HTMLBody.getElementsByClassName("compInfoSection")
For Each info In infos
    If info.getElementsByTagName("div")(0).innerText = "Email" Then ActiveCell.Offset(0,1).Value = info.getElementsByTagName("div")(1).outerHTML
Next
Set IE = nothing
End Sub

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)