excel数据获取的网站
请任何人使用VBA帮助从网站获取数据到excel,我需要excel单元格中的属性地址:excel数据获取的网站,excel,vba,Excel,Vba,请任何人使用VBA帮助从网站获取数据到excel,我需要excel单元格中的属性地址: Option Explicit Sub test() Dim ie As New InternetExplorer ie.navigate "xyz.org" ie.Visible = True Do DoEvents Loop Until ie.readyState = READYSTATE_COMPLETE Dim doc As HTMLDocument Set doc =
Option Explicit
Sub test()
Dim ie As New InternetExplorer
ie.navigate "xyz.org"
ie.Visible = True
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Dim doc As HTMLDocument
Set doc = ie.document
ie.document.all("input-search-field").Value = Range("b1").Value
Dim obj As Object
For Each obj In ie.document.getElementsByTagName("BUTTON")
If obj.className = "btn btn-default search-button" Then
obj.Click
Exit For
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Dim isPropertyAddr As Boolean
isPropertyAddr = ie.document.getElementById("LoanObject").ie.document.getelementbytagname("SPAN")
isPropertyAddr = True
Debug.Print ie.document.getattributes("classname"), ie.document.getattributes("tagname")
MsgBox obj.innerText
试试这样的方法
IsAddressFound = False
For Each obj In ie.document.getElementById("LoanObject").getElementsByTagname("SPAN")
If InStr(obj.Innertext, "Property Address") > 0 Then
IsAddressFound = True
End If
If IsAddressFound Then
Debug.Print obj.Innertext 'Your address populates here
IsAddressFound = False
End If
Next
谢谢我添加了图片太好了!我现在看到了。我会循环所有
span
元素,寻找一个内部文本为“Property Address”的元素,然后设置一个标志,以便在下一次迭代(下一个span)中,我可以获取下一个span的内部文本。我试过了,但对我不起作用。你能告诉我你在这里可以使用的确切代码吗?