“重定向”后,Excel VBA网站登录停滞

时间:2019-01-28 19:02:42

标签: excel vba internet-explorer web-scraping

我最终希望将Excel VBA与InternetExplorer结合使用,以从网页中抓取数据。

该方案要求登录到一个网站页面,然后重定向到另一个页面,在该页面上需要另一个数据条目来触发包含我最终想要的数据的响应。

我的代码(已编辑)成功执行了初始登录并到达了重定向的页面,但是在该页面上进行数据输入之前它停滞了。我没有收到任何错误通知。

我无法找到解决问题的方法,但是我认为这与网站页面重定向有关。有趣的是,如果我省略Application.Wait,则执行将尝试在登录的第一阶段使用紧随其后的(“ name”)。Value。如果有人也可以解释,我会很感兴趣。

任何帮助或指导将不胜感激。

Dim IE As InternetExplorerMedium
Set IE = New InternetExplorerMedium
IE.Visible = True
IE.navigate "http://something/Login.aspx"
Do Until IE.readyState = 4: DoEvents: Loop
Do While IE.Busy: DoEvents: Loop
IE.document.getElementById("name").Value = "signin"
IE.document.getElementById("password").Value = "pword"
IE.document.getElementById("btnValidate").Click
Do While IE.Busy: DoEvents: Loop
Do Until IE.readyState = 4: DoEvents: Loop
'Now at redirected page
Application.Wait (Now + TimeValue("0:00:08"))
'This is where execution stalls
IE.document.getElementById("name").Value = "identification"
IE.document.getElementById("btnValidate").Click

0 个答案:

没有答案