使用VBA插入标签值

时间:2018-12-13 05:11:08

标签: javascript html vba web-scraping

HTML代码:

<div class="col-md-6 ng-scope" data-ng-repeat="x in myData ">
    <div class="list-group ng-binding">
        <label for="Which is the cinema hall closest to your residence?"></label>Which is the cinema hall closest to your residence?
        <input name="email2" class="form-control ng-touched ng-not-empty ng-dirty ng-valid-parse ng-valid ng-valid-required" required="required" type="text" autocomplete="off" data-ng-required="isRequired" data-ng-model="quesAnsModel.answer[x.id]">
    </div>
</div>

如何使用VBA excel插入带有标签““哪个电影院最靠近您的住所?”的文本框的值?

ie.document.getElementsByClassName("col-md-6 ng-scope").value

1 个答案:

答案 0 :(得分:2)

使用css属性=值选择器很容易阅读

ie.document.querySelector("[for='Which is the cinema hall closest to your residence?']")

标签通常就是这样。如果您实际上需要相邻的输入框(尽管显示为电子邮件?),则可以使用相邻的同级组合器来定位以下输入框

ie.document.querySelector("[for='Which is the cinema hall closest to your residence?'] + input").value = ""