【发布时间】:2020-05-30 18:09:44
【问题描述】:
这是我第一次尝试从网页中提取 Excel 报告。我的代码应该如何工作的顺序如下:
- 初始 URL - 将网站主页(保存在浏览器中的用户 ID 和密码自动登录) - image1
- 点击“报告”
- 出现新页面 (image2)
- 从下拉模块中选择。
- 从 dropdown_reports 中选择适当的。
- 在 dropdown_reports 中的选择会创建一个新的 dropdown_project。
- 从下拉项目中选择
- 点击下载报告 (image3)
-
给出下载路径。
我能够到达第 3 点,但无法继续前进。 在 dropdown_module 上使用检查元素时,我得到了代码 (image4)
我目前的使用情况如下:
Set IE = CreateObject("InternetExplorer.Application")
URL = Range("hr_url").Value
IE.Visible = True
IE.navigate URL
Application.StatusBar = " is loading. Please wait..."
Do While IE.readyState = 4: DoEvents: Loop
Do Until IE.readyState = 4: DoEvents: Loop
Application.StatusBar = " Loaded"
Set doc = IE.document
For Each element In doc.all
If InStr(element.ID, "08191") > 0 Then
If InStr(element.ID, "AppPress:12") Then
element.Focus
element.Click
End If
End If
Next element
Application.Wait (5)
Do
DoEvents
Loop Until IE.readyState <> 4
Set doc = IE.document
For Each element In doc.all
If InStr(element.ID, "0261") > 0 Then
If InStr(element.ID, "AppPress:6") Then
MsgBox "element is found"
element.Options(0).Selected = True
End If
End If
Next element
代码无法找到下拉元素并选择所需的 0 索引。谁能建议这里有什么问题?
【问题讨论】: