我需要帮助单击一个按钮,然后使用 VBA 在网页上选择选项。
网页链接:https ://clinicaltrials.gov/ct2/results?cond=&term=Medpace&cntry=&state=&city=&dist=
我需要点击“显示/隐藏列”,然后选择“学习类型”、“阶段”、“赞助商/合作者”、“注册人数”、“NCT 号码”、“学习开始”、“学习完成”和“最后更新”发布”。
“显示/隐藏列”按钮的类:.getElementsByClassName("dt-button buttons-collection buttons-colvis").click
Private Sub Workbook_Open()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.application")
With IE
.Visible = True
.Navigate ("https://clinicaltrials.gov/ct2/results?cond=&term=Medpace&cntry=&state=&city=&dist=")
While .Busy Or .readyState <> 4: DoEvents: Wend
With IE.document
IE.Refresh
.getElementsByClassName("dt-button buttons-collection buttons-colvis").click
.querySelector("#save-list-link").click
.querySelector("#number-of-studies option:last-child").Selected = True
' .querySelector("#which-format option:fourth-child").Selected = True
' .querySelector("#which-format").selectedIndex = 3
' .querySelector ("#number-of-studies").selectedIndex = 1
' .querySelector("[value=csv]").click
.querySelector("#submit-download-list").click
' Set div = IE.document.getElementById("save-list-link")
' div.FireEvent "onclick"
End With
Application.Wait Now + TimeSerial(0, 0, 10)
Application.SendKeys "%+s", True
Application.Wait Now + TimeSerial(0, 0, 10)
.Quit
' For Each elt In IE.document.getElementById("number-of-studies")
' If InStr(elt.innerText, "Found") > 0 Then elt.click: Exit For
' Next elt
' Set div4 = IE.document.getElementById("submit-download-list")
' div4.click
End With
End Sub