我无法专门找到这个问题,希望我没有错认为它是一个旧问题的新变体。
我希望能够在(不一致的)p.red 元素 text() 之后选择表格,其中 'p' 不包含文本“Alphabetical”但包含文本“OVERALL”..
DOM 看起来像这样:
<p class=red>Some Text</p>
<table class="newclass">
<tr></tr>
<tr></tr>
</table>
<p class=red>Some Text</p>
<table class="newclass">
<tr></tr>
<tr></tr>
</table>
<p class=red>OVERALL</p>
<table class="newclass">
<tr></tr>
<tr></tr>
</table>
- 该表在每一页都有不同的计数。
我想获得那个 p 标签的 text() ,但也想直接在它之后获得表格。同样,text() 包含“OVERALL”但不包含“ALPHABETICAL”.. 我应该构建一个数组并 .reject() 没有匹配的元素吗?目前我不确定,而且我对使用 Ruby 和 Mechanize 还很陌生,在此先感谢您的帮助!