【问题标题】:What would be the appropriate syntax for clicking the "send to" drop down menu? (See image for reference)单击“发送到”下拉菜单的适当语法是什么? (参见图片以供参考)
【发布时间】:2018-11-29 03:16:04
【问题描述】:

我想知道单击网页上的“发送到”按钮的最佳语法是什么。

这是目前为止的代码:

Option Explicit
Sub Search_PubMedandCochrane()

Dim IE As New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate "https://www.ncbi.nlm.nih.gov/pubmed"

Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop

Debug.Print IE.LocationName, IE.LocationURL

IE.Document.forms("EntrezForm").elements("term").Value = Range("B4")

IE.Document.forms("EntrezForm").elements("search").Click



End Sub

【问题讨论】:

    标签: html excel vba web-scraping


    【解决方案1】:

    尝试使用attribute = value CSS 选择器通过属性及其值来定位元素。

    IE.document.querySelector("[sourcecontent='send_to_menu']").click
    

    在尝试点击之前,请确保您有足够的页面加载等待时间。至少你需要

    While IE.Busy Or IE.readyState < 4: DoEvents: Wend 
    IE.document.querySelector("[sourcecontent='send_to_menu']").click
    

    你也可以使用

    IE.document.querySelector("#sendto > a").click
    

    【讨论】:

      猜你喜欢
      • 2021-02-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-17
      • 1970-01-01
      • 2022-11-03
      • 1970-01-01
      • 1970-01-01
      • 2018-07-07
      相关资源
      最近更新 更多