【发布时间】:2011-11-21 03:48:23
【问题描述】:
我无法专门找到这个问题,希望它是旧问题的新变体,我没有错。
我希望能够在(不一致的)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 还很陌生,在此先感谢您的帮助!
【问题讨论】:
标签: ruby dom mechanize scraper