如何从给定的HTML中将“谁是你的第一个雇主?”的innerText提取到Excel中

时间:2017-04-01 10:25:14

标签: html vba

<div class="ContainerFieldControlHoriz" style="width: 400px;">
    <label title="Who was your first employer?" id="dnn_ctr1854_ChallengeQuestion_ChallengeQuestionCmnTextBox_ControlLabel">Who was your first employer?</label>
</div>

我的代码是

Set htmlsecurityquestion = htmldoc.getElementById("dnn_ctr1854_ChallengeQuestion_ChallengeQuestionCmnTextBox_ControlLabel")
Range("A1").Value = htmlsecurityquestion.innerText

但它不起作用

1 个答案:

答案 0 :(得分:0)

您可以通过属性集合访问此值,而不是通过innerText。你的第二行应该是:

Range("A1").Value = htmlsecurityquestion.Attributes["title"].Value;