【发布时间】:2018-06-30 05:20:17
【问题描述】:
我需要向此网页http://kepler.sos.ca.gov/ 提供输入,然后在单击提交按钮后收集信息。第一部分(输入+点击提交)运行顺利:
Dim ie As InternetExplorer
'to refer to the HTML document returned
Dim html As HTMLDocument
'open Internet Explorer in memory, and go to website
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "http://kepler.sos.ca.gov/"
'Wait until IE is done loading page
Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
Set html = ie.document
html.getElementById("ctl00_content_placeholder_body_BusinessSearch1_RadioButtonList_SearchType_1").Click
html.getElementById("ctl00_content_placeholder_body_BusinessSearch1_TextBox_NameSearch").innerText = "global telematic solutions, LLC"
html.getElementById("ctl00_content_placeholder_body_BusinessSearch1_Button_Search").Click
Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
然后我需要在新页面的 HTML 脚本中获取元素的内部文本。问题是我无法从新页面的源代码中提取信息。特别是我希望能够得到类似的东西
Dim SearchCount As String
SearchCount = html.getElementById("ctl00_content_placeholder_body_SearchResults1_TextInfoCorp1_TextInfoSearchResultCounts1_Label_RowCount").innerText
问题是“html”仍然指的是前一页。我如何引用新的?新页面的url和上一个一样。
【问题讨论】:
标签: html vba web-scraping