【发布时间】:2018-06-18 19:58:01
【问题描述】:
我需要从网站获取数据
我正在使用SHDocVw.InternetExplorer 和MSHTML.HTMLDocument 并获取数据。
在获取每条记录并为每条记录创建新实例后,我正在使用 set IE = Nothing 和 IE.Quit,但只要 IE 停止响应或崩溃,宏就会停止。
我只想在 IE 崩溃时跳过该记录并从下一个记录恢复
是否可以忽略来自 IE 的每个弹出窗口并从下一条记录恢复以获取数据。
For Each Cell In Selection
URL = Cell.Value
Set IE = New SHDocVw.InternetExplorer
With IE
.navigate URL
.Visible = True
Do While .readyState <> READYSTATE_COMPLETE Or .Busy = True
DoEvents
Loop
Application.Wait (Now + TimeValue("00:00:05"))
Set Doc = .document
'*Fetch the Elements and Records by using getElementbyid*
End With
Set IE = Nothing
IE.quit
Next Cell
我也尝试过使用 selenium,但面临同样的问题。 我只想忽略 IE 是否崩溃或不响应特定记录并获取下一个记录。 IE 在 2000 条记录和 100 条记录之后崩溃。 我需要在一夜之间运行这个宏。 我正在使用 IE 11 和 Excel 2010
【问题讨论】:
标签: vba selenium internet-explorer web-scraping internet-explorer-11