从不在源代码中的网页提取数据
我想在Excel中编写一个macros,从下面的网页中提取数据:
http://www.richmond.com/data-center/salaries-virginia-state-employees-2013/?appSession=673718284851033&RecordID=101177&PageID=3&PrevPageID=2&cpipage=1&CPIsortType=&CPIorderBy=&cbCurrentRecordPosition=1
我遇到的问题是员工信息数据不在页面源代码中,所以当我使用下面的代码(其中NextPage设置为上述URL)时, responseText
不包含我正在查找的数据。
With CreateObject("msxml2.xmlhttp") .Open "GET", NextPage, False .Send htm.body.innerHtml = .responseText End With
我可能是错的,但我相信数据包含在页面的DOM中。 有人可以帮助我了解如何使用VBScript显示(即在应用javascript修改后)下载此页面的内容?
使用InternetExplorer.Application
COM对象应该可以访问实际的DOM树:
url = "http://www.richmond.com/..." Set ie = CreateObject("InternetExplorer.Application") ie.Visible = True ie.Navigate url Do WScript.Sleep 100 Until ie.ReadyState = 4 Set elem = ie.Document.getElementById("...")
如果这不起作用,你可能不得不诉诸像PhantomJS 。