如果您想在不使用 getElementByID 的情况下检索 div 的 innerHTML(见下文)(考虑到该网站有多个 div 以 'quote' 作为 id),而是通过引用 'field name' (field="bid")。你会怎么做?
<div nowrap="nowrap" id="quote" class="realtimeDetailLayer" source="lightstreamer"
style="display:inline" table="LS_ProductDetails_TabID" item="X0000010600NL0010379129"
field="bid">0,28</div>
我想从现有网站检索信息。见下文。在这里你可以看到几个 div 的 ID 相同
<tbody>
<tr>
<td style="text-align:right;width:auto;padding:8px 0px;"><nobr>Ref.</nobr>:</td>
<td class="ext04" style="white-space:nowrap;width:12%;font-weight:bold;">
EUR
<strong><div nowrap=nowrap id="quote" class="realtimeDetailLayer" source="lightstreamer" style="display:inline" table="LS_ProductDetails_TabID" item="X0000010600NL0010379129" field="reference">350,85
</div></strong>
</td>
<td style="text-align:right;width:auto;padding:8px 0px;"><nobr>Bied</nobr>:</td>
<td class="ext04" style="white-space:nowrap;width:12%;font-weight:bold;">
EUR
<div nowrap=nowrap id="quote" class="realtimeDetailLayer" source="lightstreamer" style="display:inline" table="LS_ProductDetails_TabID" item="X0000010600NL0010379129" field="bid">0,28</div>
</td>
<td style="text-align:right;width:auto;padding:8px 0px;">
<nobr>Laat</nobr>:
</td>
<td class="ext04" style="white-space:nowrap;width:12%;font-weight:bold;">
EUR
<div nowrap=nowrap id="quote" class="realtimeDetailLayer" source="lightstreamer" style="display:inline" table="LS_ProductDetails_TabID" item="X0000010600NL0010379129" field="ask">0,29
</div>
</td>
<td style="text-align:right;width:auto;padding:8px 0px;"><nobr>%</nobr>:</td>
<td class="ext04" style="white-space:nowrap;width:12%;font-weight:bold;">
<div nowrap=nowrap id="quote" class="realtimeDetailLayer" source="lightstreamerGeneratedValues" style="display:inline" table="LS_ProductDetails_TabID" item="X0000010600NL0010379129" field="midchangepercent"><span class="extNegative"><nobr>-50,88 %</nobr></span>
</div>
</td>
</tr>
</tbody>