如何获取对照组的字段

时间:2018-12-05 20:50:47

标签: html vba web-scraping

我正在尝试访问网站上的字段并为其写答案。我一辈子都无法弄清楚它的名称或引用方式。我可以看到它位于表格上。上面有3个字段,我想要第一个。似乎没有任何ID可使用。我尝试遍历整个过程以打印标签名称,例如,我使用VBA打开网页等。

这是HTML:

<ng-form class="form ng-pristine ng-valid" name="policySearchForm">
   <div class="gw-control-group-wrapper">
      <div class="form-item select-form-fli form-item-grid-fli ng-isolate-scope" model="policySearchRequestView.policyNumber" label="Policy Number" gw-pl-ctrl-group="">
         <div class="gw-control-group" aria-hidden="false" ng-class="{ 'gw-error': showError(), 'gw-inline-control-group': inline, 'gw-control-group': !inline, 'gw-control-group-focused' : focused, 'required-fli': model.aspects.required }" ng-show="isVisible()">
            <!-- ngIf: label -->
            <label title="" class="ng-scope gw-control-label" ng-class="{'gw-control-inline-label': inline, 'gw-control-label': !inline}" ng-if="label">
               <span class="ng-binding">
                  Policy Number
                  <!-- Information icon for Useful Hints -->
                  <!-- ngIf: usefulHint -->
               </span>
               <span class="gw-required-asterisk ng-hide" aria-hidden="true" ng-show="(model.aspects.required &amp;&amp; !readonly) || (showAsterisk &amp;&amp; !readonly &amp;&amp; label === 'Date Of Birth')">*</span>
            </label>
            <!-- end ngIf: label -->
            <div class="gw-controls" ng-class="{'gw-inline-controls': inline, 'gw-controls': !inline}">
               <ng-transclude>
                  <input tabindex="0" class="ng-pristine ng-valid ng-scope ng-touched" aria-invalid="false" type="text" ng-model="policySearchRequestView.policyNumber.value" ng-keypress="($event.which === 13)?searchPolicies():0">
               </ng-transclude>
               <div class="gw-inline-messages" aria-hidden="false" ng-show="!readonly">
                  <!-- ngRepeat: errorMessage in model.aspects.validationMessages track by $index -->
               </div>
            </div>
         </div>
      </div>
      <!-- ngIf: policySearchRequestView.IsPersonalPolicy === 'true' -->
      <div class="form-item-grid-fli ng-scope ng-isolate-scope" ng-if="policySearchRequestView.IsPersonalPolicy === 'true'" model="policySearchRequestView.firstName" label="First Name" gw-pl-ctrl-group="">
         <div class="gw-control-group" aria-hidden="false" ng-class="{ 'gw-error': showError(), 'gw-inline-control-group': inline, 'gw-control-group': !inline, 'gw-control-group-focused' : focused, 'required-fli': model.aspects.required }" ng-show="isVisible()">
            <!-- ngIf: label -->
            <label title="" class="ng-scope gw-control-label" ng-class="{'gw-control-inline-label': inline, 'gw-control-label': !inline}" ng-if="label">
               <span class="ng-binding">
                  First Name
                  <!-- Information icon for Useful Hints -->
                  <!-- ngIf: usefulHint -->
               </span>
               <span class="gw-required-asterisk ng-hide" aria-hidden="true" ng-show="(model.aspects.required &amp;&amp; !readonly) || (showAsterisk &amp;&amp; !readonly &amp;&amp; label === 'Date Of Birth')">*</span>
            </label>
            <!-- end ngIf: label -->
            <div class="gw-controls" ng-class="{'gw-inline-controls': inline, 'gw-controls': !inline}">
               <ng-transclude>
                  <input tabindex="0" class="ng-pristine ng-valid ng-scope ng-touched" aria-invalid="false" type="text" ng-model="policySearchRequestView.firstName.value" ng-keypress="($event.which === 13)?searchPolicies():0">
                  <!--<div class="exact-match-fli">-->
                  <!--<div class="gw-control-label">-->
                  <!--{{'agent.views.policy-landing.Exact Match' | translate}}-->
                  <!--<input type="checkbox"-->
                  <!--ng-model="policySearchRequest.isFirstNameExact"-->
                  <!--class="gw-check"-->
                  <!--id="firstNamePolicyCheckboxLabel{{$index}}">-->
                  <!--<label class="gw-checkbox" id="firstNamePolicyCheckboxLabel" for="firstNamePolicyCheckboxLabel{{$index}}"></label>-->
                  <!--</div>-->
                  <!--</div>-->
               </ng-transclude>
               <div class="gw-inline-messages" aria-hidden="false" ng-show="!readonly">
                  <!-- ngRepeat: errorMessage in model.aspects.validationMessages track by $index -->
               </div>
            </div>
         </div>
      </div>
      <!-- end ngIf: policySearchRequestView.IsPersonalPolicy === 'true' -->
      <!-- ngIf: policySearchRequestView.IsPersonalPolicy == 'true' -->
      <div class="form-item-grid-fli full-width-input-fli ng-scope ng-isolate-scope" ng-if="policySearchRequestView.IsPersonalPolicy == 'true'" model="policySearchRequestView.lastName" label="Last Name" gw-pl-ctrl-group="">
         <div class="gw-control-group" aria-hidden="false" ng-class="{ 'gw-error': showError(), 'gw-inline-control-group': inline, 'gw-control-group': !inline, 'gw-control-group-focused' : focused, 'required-fli': model.aspects.required }" ng-show="isVisible()">
            <!-- ngIf: label -->
            <label title="" class="ng-scope gw-control-label" ng-class="{'gw-control-inline-label': inline, 'gw-control-label': !inline}" ng-if="label">
               <span class="ng-binding">
                  Last Name
                  <!-- Information icon for Useful Hints -->
                  <!-- ngIf: usefulHint -->
               </span>
               <span class="gw-required-asterisk ng-hide" aria-hidden="true" ng-show="(model.aspects.required &amp;&amp; !readonly) || (showAsterisk &amp;&amp; !readonly &amp;&amp; label === 'Date Of Birth')">*</span>
            </label>
            <!-- end ngIf: label -->
            <div class="gw-controls" ng-class="{'gw-inline-controls': inline, 'gw-controls': !inline}">
               <ng-transclude>
                  <input tabindex="0" class="ng-pristine ng-valid ng-scope ng-touched" aria-invalid="false" type="text" ng-model="policySearchRequestView.lastName.value" ng-keypress="($event.which === 13)?searchPolicies():0">
                  <!--<div class="exact-match-fli">-->
                  <!--<div class="gw-control-label">-->
                  <!--{{'agent.views.policy-landing.Exact Match' | translate}}-->
                  <!--<input type="checkbox"-->
                  <!--ng-model="policySearchRequest.isLastNameExact"-->
                  <!--class="gw-check"-->
                  <!--id="lastNamePolicyCheckboxLabel{{$index}}">-->
                  <!--<label class="gw-checkbox" id="lastNamePolicyCheckboxLabel" for="lastNamePolicyCheckboxLabel{{$index}}"></label>-->
                  <!--</div>-->
                  <!--</div>-->
               </ng-transclude>
               <div class="gw-inline-messages" aria-hidden="false" ng-show="!readonly">
                  <!-- ngRepeat: errorMessage in model.aspects.validationMessages track by $index -->
               </div>
            </div>
         </div>
      </div>
      <!-- end ngIf: policySearchRequestView.IsPersonalPolicy == 'true' -->
      <!-- ngIf: policySearchRequestView.IsPersonalPolicy === 'false' -->
   </div>
</ng-form>

任何人都可以朝正确的方向指出我如何确定如何引用它或输入框名称吗?

1 个答案:

答案 0 :(得分:0)

这是显示的HTML的第一个输入框。我将结合CSS属性=值选择器和元素选择器来定位

input[ng-model='policySearchRequestView.policyNumber.value']

假设使用IE:

ie.document.querySelector("input[ng-model='policySearchRequestView.policyNumber.value']")

您可以使用相同的语法,但是将属性值替换为

policySearchRequestView.firstName.value

policySearchRequestView.lastName.value

对于其他人。