我有这样的 HTML:
<div style = 'display: hidden'>
<span class = "thing">text</span>
</div>
<div style = 'display: block'>
<span class = "thing">text</span>
</div>
<div style = 'display: hidden'>
<span class = "thing">text</span>
</div>
我只想选择<span>
出现在未隐藏 div 中的“事物”类的标签。我怎样才能用 Nokogiri 宝石做到这一点?
这就是我正在尝试的:
page = Nokogiri::HTML(open(@url))
item_list = page.css("div[@style != 'display: hidden'] span.thing")