Excel VBA为IE页面上的输入框添加值

时间:2018-05-13 22:54:44

标签: html excel vba

第一次尝试这个。

我在网页中有以下HTML,我正在使用ExcelVBA来抓取数据。

<div class="program-filters">
   <span>Search for&nbsp;</span>
   <a>
      any gender&nbsp;<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&nbsp;<img src="/site/image/svg/DownArrow.svg" alt="Down Arrow" class="down-arrow-icon">
   </a>
   to
   <a>
      play&nbsp;<img src="/site/images/svg/DownArrow.svg" alt="Down Arrow" class="down-arrow-icon">
   </a>
   <br class="sm-hide md-hide lg-hide">&nbsp;near&nbsp;
   <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或类。使用jQuery,我会在div class="program-filters"内找到此输入。

谢谢

1 个答案:

答案 0 :(得分:1)

假设您已经有一个HTML文档可以使用,您可以这样做:

OUTCOMING call started
2018-05-14 01:50:04.770308+0300 app-ios[9239:1188745] PJSIP(1):  pjsua_media.c !..Unable to resolve transport bind address: gethostbyname() has returned error (PJ_ERESOLVE) [status=70018]
2018-05-14 01:50:04.770354+0300 app-ios[9239:1188745] PJSIP(1):  pjsua_media.c  ..Unable to create RTP/RTCP socket: gethostbyname() has returned error (PJ_ERESOLVE) [status=70018]
2018-05-14 01:50:04.770375+0300 app-ios[9239:1188745] PJSIP(1):  pjsua_media.c  ..Error creating media transport: gethostbyname() has returned error (PJ_ERESOLVE)
2018-05-14 01:50:04.770394+0300 app-ios[9239:1188745] PJSIP(1):   pjsua_call.c  .Error initializing media channel: gethostbyname() has returned error (PJ_ERESOLVE) [status=70018]
interruptCall
2018-05-14 01:50:31.465743+0300 app-ios[9239:1187468] PJSIP(2):    pjsua_acc.c  ...SIP registration failed, status=408 (Request Timeout)
2018-05-14 01:50:31.466269+0300 app-ios[9239:1187284] Did stop listening for connections due to error Generic Error
2018-05-14 01:51:09.154605+0300 app-ios[9239:1187468] PJSIP(1): tlsc0x12681602  TLS connect() error: Operation timed out [code=120060]

如果这始终是此页面上的第一个输入框,它将起作用。单击按钮提交以这种方式填充的输入框有时需要更改输入框的类,以模拟手动填充此字段时发生的更改,否则JS验证会将该字段视为空。