第一次尝试这个。
我在网页上有以下HTML
,我正在使用Excel
和VBA
来抓取数据。
<div class="program-filters">
<span>Search for </span>
<a>
any gender <img src="/site/images/svg/DownArrow.svg" alt="Down Arrow" class="down-arrow-icon">
</a>
<span class="xs-hide">,</span>
<br class="sm-hide md-hide lg-hide">
<a>
all ages <img src="/site/image/svg/DownArrow.svg" alt="Down Arrow" class="down-arrow-icon">
</a>
to
<a>
play <img src="/site/images/svg/DownArrow.svg" alt="Down Arrow" class="down-arrow-icon">
</a>
<br class="sm-hide md-hide lg-hide"> near
<div style="display: inline-block;">
<input role="combobox" aria-autocomplete="list" autocomplete="off" value="SEARCH VALUE HERE">
</div>
<a class="in-map-btn btn btn-primary btn-go btn-mobile-fixed">GO</a>
</div>
如何定位input role="combobox"
,因为它没有id或class。使用jQuery
,我会在div class="program-filters"
中找到这个输入。
谢谢
假设您已经有一个HTML文档可以使用,您可以这样做:
myHTMLDoc.GetElementsbyTagName("INPUT")(0).value = myValue
如果它始终是此页面上的第一个输入框,它将起作用。单击按钮以提交以这种方式填充的输入框有时需要更改输入框的类,以模拟手动填充此字段时发生的更改,否则JS验证将认为该字段为空。