VBA:从新页面提取HTML(相同url)

VBA:从新页面提取HTML(相同url),html,vba,web-scraping,Html,Vba,Web Scraping,我需要向该网页提供输入,然后在单击“提交”按钮后收集信息。第一部分(输入+单击提交)运行平稳: 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.naviga

我需要向该网页提供输入,然后在单击“提交”按钮后收集信息。第一部分(输入+单击提交)运行平稳:

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”仍然是指上一页。我怎么说新的呢?新页面的url与上一个页面相同。

您需要在最后一次单击后再设置一个
html=ie.document
,以便获得新的文档内容

html.getElementById("ctl00_content_placeholder_body_BusinessSearch1_Button_Search").Click 
While ie.Busy Or ie.READYSTATE < 4: DoEvents: Wend
Set html = ie.document  '<== New HTML document content
html.getElementById(“ctl00\u内容\u占位符\u正文\u业务搜索1\u按钮\u搜索”)。单击
当ie.Busy或ie.READYSTATE<4:DoEvents:Wend时

设置html=ie.document'在最后一次单击后,您需要另一个
设置html=ie.document
,以便获得新的文档内容

html.getElementById("ctl00_content_placeholder_body_BusinessSearch1_Button_Search").Click 
While ie.Busy Or ie.READYSTATE < 4: DoEvents: Wend
Set html = ie.document  '<== New HTML document content
html.getElementById(“ctl00\u内容\u占位符\u正文\u业务搜索1\u按钮\u搜索”)。单击
当ie.Busy或ie.READYSTATE<4:DoEvents:Wend时
设置html=ie.document'