我想在一个网页中检索电子邮件地址,只要有这个html即可:
`<div id="responseDiv" style="background-color:#EBECED;width: 450px;">
<font style="letter-spacing: 0pt" size="3" face="Arial"
color="#336699">
<a href="mailto:recrutamento@sgp.pt?subject=Resposta Anuncio Net- Empregos: TI SQL e VB.net" target="_blank">**recrutamento@sgp.pt**
<div></div>
<div></div>
</a>
</font></div>
`
到目前为止,我已经尝试了以下操作,该操作可以解决该页面中除我想要的电子邮件地址之外的所有内容:
Dim dataEle As Object, vElemento As String, tit as string
Set dataEle =Doc.getElementsByTagName("p") ' also tryed with element "a"
For Each element In dataEle
tit = element.getAttribute("href")
MsgBox (tit)
Next
可能是因为元素“ a”是Div的一部分吗? (responseDiv) 谢谢
答案 0 :(得分:0)
I did test your code associated with your html div string with many emails as in the attached image to ensure you.
Just remember if that html div string is constants string, this solution will work just like you want:
Private Sub CmdRetrieveHrefInsideDiv_Click()
Dim test As String
Dim frstWrd As String
test = Text1.Value
frstWrd = Split(test, ":")(4)
Dim X As Integer
X = InStr(frstWrd, "?")
Dim MyEmail As String
MyEmail = Split(frstWrd, "?")(0)
MsgBox MyEmail
End Sub
I hope this can help you ^_^
答案 1 :(得分:0)
非常感谢,它就像一种魅力